From 669afe481dc12dc1cbd6c92538e34482f9622490 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 13 Aug 2022 20:19:21 +0600 Subject: [PATCH] add defaultMessageFormatterWithErrorPrint --- CHANGELOG.md | 2 ++ src/commonMain/kotlin/KSLogTypealiases.kt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 382fbc3..f233ee9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.5.1 +* New property `defaultMessageFormatterWithErrorPrint` for messages format with errors + ## 0.5.0 * `Kotlin`: `1.7.10` diff --git a/src/commonMain/kotlin/KSLogTypealiases.kt b/src/commonMain/kotlin/KSLogTypealiases.kt index 0e2b5c8..5660ae0 100644 --- a/src/commonMain/kotlin/KSLogTypealiases.kt +++ b/src/commonMain/kotlin/KSLogTypealiases.kt @@ -5,4 +5,4 @@ typealias MessageFormatter = (l: LogLevel, t: String?, m: Any, Throwable?) -> St inline fun MessageFormatter(noinline formatter: MessageFormatter) = formatter typealias MessageFilter = (l: LogLevel, t: String?, Throwable?) -> Boolean val defaultMessageFormatter: MessageFormatter = { l, t, m, _ -> "[$l] ${t ?.let { "$it " } ?: ""}- $m" } - +val defaultMessageFormatterWithErrorPrint: MessageFormatter = { l, t, m, e -> "[$l] ${t ?.let { "$it " } ?: ""}- $m${e ?.let { ": ${it.stackTraceToString()}" } ?: ""}" }