Extracted determining arguments
This commit is contained in:
parent
87e272565f
commit
d38f7b224b
|
@ -85,19 +85,23 @@ open class Slf4jLogger(protected val slf4jLogger: org.slf4j.Logger) : Logger {
|
||||||
|
|
||||||
val message = messageCreator()
|
val message = messageCreator()
|
||||||
|
|
||||||
if (exception != null) {
|
val args = determineArguments(exception, arguments)
|
||||||
|
|
||||||
|
logOnLevel(message, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun determineArguments(exception: Throwable?, arguments: Array<out Any>): Array<out Any> {
|
||||||
|
return if (exception != null) {
|
||||||
if (arguments.isEmpty()) {
|
if (arguments.isEmpty()) {
|
||||||
logOnLevel(message, arrayOf(exception))
|
arrayOf(exception)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
val argumentsIncludingException: MutableList<Any> = mutableListOf(exception)
|
val argumentsIncludingException: MutableList<Any> = mutableListOf(exception)
|
||||||
argumentsIncludingException.addAll(0, arguments.toList())
|
argumentsIncludingException.addAll(0, arguments.toList())
|
||||||
|
|
||||||
logOnLevel(message, argumentsIncludingException.toTypedArray())
|
argumentsIncludingException.toTypedArray()
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
arguments
|
||||||
logOnLevel(message, arguments)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue