From 0e01534562c6680bc759334a9f38ada15414dd0e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 31 Jul 2022 19:06:57 +0600 Subject: [PATCH] setDefaultKSLog and KSLog#plus(KSLog) --- CHANGELOG.md | 3 +++ src/commonMain/kotlin/KSLog.kt | 2 ++ src/commonMain/kotlin/utils/Combination.kt | 9 +++++++++ 3 files changed, 14 insertions(+) create mode 100644 src/commonMain/kotlin/utils/Combination.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 1794c2a..3b378f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.4.2 +* Add `setDefaultKSLog` +* Add `plus` operation for two `KSLog` instances to call them both on each log performing + ## 0.4.1 * Fixes in resolution ambiguity for functions with messages diff --git a/src/commonMain/kotlin/KSLog.kt b/src/commonMain/kotlin/KSLog.kt index be76ca4..7d67fe5 100644 --- a/src/commonMain/kotlin/KSLog.kt +++ b/src/commonMain/kotlin/KSLog.kt @@ -110,3 +110,5 @@ fun KSLog( ).filtered { l, _, _ -> minLoggingLevel.ordinal <= l.ordinal } + +fun setDefaultKSLog(newDefault: KSLog) { KSLog.default = newDefault } diff --git a/src/commonMain/kotlin/utils/Combination.kt b/src/commonMain/kotlin/utils/Combination.kt new file mode 100644 index 0000000..9e43fd1 --- /dev/null +++ b/src/commonMain/kotlin/utils/Combination.kt @@ -0,0 +1,9 @@ +package dev.inmo.kslog.common.utils + +import dev.inmo.kslog.common.CallbackKSLog +import dev.inmo.kslog.common.KSLog + +infix operator fun KSLog.plus(other: KSLog) = CallbackKSLog { l, t, m, e -> + this@plus.performLog(l, t, m, e) + other.performLog(l, t, m, e) +}