2022-07-31 13:06:57 +00:00
|
|
|
package dev.inmo.kslog.common.utils
|
|
|
|
|
|
|
|
import dev.inmo.kslog.common.CallbackKSLog
|
|
|
|
import dev.inmo.kslog.common.KSLog
|
|
|
|
|
2023-11-18 11:15:23 +00:00
|
|
|
/**
|
|
|
|
* Will send [KSLog.performLog] of both [this] and [other] [KSLog] instances. In case when [this] will throw exception
|
|
|
|
* result logger will rethrow it. After it, if [other] will throw exception - will also rethrow it
|
|
|
|
*/
|
2022-07-31 13:06:57 +00:00
|
|
|
infix operator fun KSLog.plus(other: KSLog) = CallbackKSLog { l, t, m, e ->
|
2022-07-31 13:13:02 +00:00
|
|
|
val resultOfFirst = runCatching {
|
|
|
|
this@plus.performLog(l, t, m, e)
|
|
|
|
}
|
|
|
|
val resultOfSecond = runCatching {
|
|
|
|
other.performLog(l, t, m, e)
|
|
|
|
}
|
|
|
|
resultOfFirst.onFailure { throw it }
|
|
|
|
resultOfSecond.onFailure { throw it }
|
2022-07-31 13:06:57 +00:00
|
|
|
}
|