From 77ca9ce25b4a6870af833501b3107a4609154857 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 31 Jul 2022 19:19:17 +0600 Subject: [PATCH] MessageFormatter factory --- CHANGELOG.md | 1 + src/commonMain/kotlin/KSLogTypealiases.kt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9978448..2062367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Add `setDefaultKSLog` and `addDefaultKSLog` * Add `plus` operation for two `KSLog` instances to call them both on each log performing * Add `KSLog` factory for simple creation of `CallbackKSLog` +* Add `MessageFormatter` factory ## 0.4.1 diff --git a/src/commonMain/kotlin/KSLogTypealiases.kt b/src/commonMain/kotlin/KSLogTypealiases.kt index d36b5a1..1a8fb1d 100644 --- a/src/commonMain/kotlin/KSLogTypealiases.kt +++ b/src/commonMain/kotlin/KSLogTypealiases.kt @@ -1,6 +1,8 @@ package dev.inmo.kslog.common typealias MessageFormatter = (l: LogLevel, t: String, m: Any, Throwable?) -> String +@Suppress("NOTHING_TO_INLINE") +inline fun MessageFormatter(noinline formatter: MessageFormatter) = formatter typealias MessageFilter = (l: LogLevel, t: String?, Throwable?) -> Boolean val defaultMessageFormatter: MessageFormatter = { l, t, m, _ -> "[$l] $t - $m" }