Also pretty printing error messages
This commit is contained in:
parent
529caeaa87
commit
20fe60d9f6
|
@ -57,12 +57,7 @@ open class MessageLogCollector(
|
||||||
|
|
||||||
open fun addMessageLog(type: MessageLogEntryType, message: String, context: MessageContext, parsedSegments: List<ReceivedSegment> = emptyList()) {
|
open fun addMessageLog(type: MessageLogEntryType, message: String, context: MessageContext, parsedSegments: List<ReceivedSegment> = emptyList()) {
|
||||||
val messageTrace = createMessageTraceString(type, context)
|
val messageTrace = createMessageTraceString(type, context)
|
||||||
|
val prettyPrintMessage = prettyPrintMessageIfRequired(message)
|
||||||
val prettyPrintMessage = if (options.collectMessageLog || options.fireCallbackOnMessageLogs || log.isDebugEnabled) { // only use CPU cycles if message will ever be used / displayed
|
|
||||||
prettyPrintFinTsMessage(message)
|
|
||||||
} else {
|
|
||||||
message
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug { "$messageTrace\n$prettyPrintMessage" }
|
log.debug { "$messageTrace\n$prettyPrintMessage" }
|
||||||
|
|
||||||
|
@ -72,10 +67,11 @@ open class MessageLogCollector(
|
||||||
open fun logError(loggingClass: KClass<*>, message: String, context: MessageContext, e: Throwable? = null) {
|
open fun logError(loggingClass: KClass<*>, message: String, context: MessageContext, e: Throwable? = null) {
|
||||||
val type = MessageLogEntryType.Error
|
val type = MessageLogEntryType.Error
|
||||||
val messageTrace = createMessageTraceString(type, context)
|
val messageTrace = createMessageTraceString(type, context)
|
||||||
|
val prettyPrintMessage = prettyPrintFinTsMessage(message) // error messages almost always get logged / displayed -> pretty print
|
||||||
|
|
||||||
LoggerFactory.getLogger(loggingClass).error(e) { messageTrace + message }
|
LoggerFactory.getLogger(loggingClass).error(e) { "$messageTrace\n$prettyPrintMessage" }
|
||||||
|
|
||||||
addMessageLogEntry(type, context, messageTrace, message, e)
|
addMessageLogEntry(type, context, messageTrace, prettyPrintMessage, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun addMessageLogEntry(type: MessageLogEntryType, context: MessageContext, messageTrace: String, message: String, error: Throwable? = null, parsedSegments: List<ReceivedSegment> = emptyList()) {
|
protected open fun addMessageLogEntry(type: MessageLogEntryType, context: MessageContext, messageTrace: String, message: String, error: Throwable? = null, parsedSegments: List<ReceivedSegment> = emptyList()) {
|
||||||
|
@ -113,6 +109,13 @@ open class MessageLogCollector(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun prettyPrintMessageIfRequired(message: String): String =
|
||||||
|
if (options.collectMessageLog || options.fireCallbackOnMessageLogs || log.isDebugEnabled) { // only use CPU cycles if message will ever be used / displayed
|
||||||
|
prettyPrintFinTsMessage(message)
|
||||||
|
} else {
|
||||||
|
message
|
||||||
|
}
|
||||||
|
|
||||||
protected open fun prettyPrintFinTsMessage(message: String): String =
|
protected open fun prettyPrintFinTsMessage(message: String): String =
|
||||||
finTsUtils.prettyPrintFinTsMessage(message)
|
finTsUtils.prettyPrintFinTsMessage(message)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue