diff --git a/common/src/jvmMain/kotlin/net/dankito/utils/multiplatform/log/Slf4jLogger.kt b/common/src/jvmMain/kotlin/net/dankito/utils/multiplatform/log/Slf4jLogger.kt index 55e0f291..64f197bd 100644 --- a/common/src/jvmMain/kotlin/net/dankito/utils/multiplatform/log/Slf4jLogger.kt +++ b/common/src/jvmMain/kotlin/net/dankito/utils/multiplatform/log/Slf4jLogger.kt @@ -85,19 +85,23 @@ open class Slf4jLogger(protected val slf4jLogger: org.slf4j.Logger) : Logger { val message = messageCreator() - if (exception != null) { + val args = determineArguments(exception, arguments) + + logOnLevel(message, args) + } + + protected open fun determineArguments(exception: Throwable?, arguments: Array): Array { + return if (exception != null) { if (arguments.isEmpty()) { - logOnLevel(message, arrayOf(exception)) - } - else { + arrayOf(exception) + } else { val argumentsIncludingException: MutableList = mutableListOf(exception) argumentsIncludingException.addAll(0, arguments.toList()) - logOnLevel(message, argumentsIncludingException.toTypedArray()) + argumentsIncludingException.toTypedArray() } - } - else { - logOnLevel(message, arguments) + } else { + arguments } }