From e76b0e72ff24f60475e8ca8186f6558beb1660de Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 15 Dec 2024 01:06:05 +0100 Subject: [PATCH] Fix padding of dates and times in log format --- .../de/staropensource/engine/logging/Processor.kt | 6 ++---- .../logging/implementation/SOSLSv2FormatBuilder.kt | 12 ++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/logging/src/main/kotlin/de/staropensource/engine/logging/Processor.kt b/logging/src/main/kotlin/de/staropensource/engine/logging/Processor.kt index 37a79bb..61166a1 100644 --- a/logging/src/main/kotlin/de/staropensource/engine/logging/Processor.kt +++ b/logging/src/main/kotlin/de/staropensource/engine/logging/Processor.kt @@ -115,13 +115,11 @@ class Processor private constructor() { if ( (channelconf.sanitizeMessage ?: ChannelSettings.global.sanitizeMessage) != false && (channelconf.permitFormatting ?: ChannelSettings.global.permitFormatting) != false - ) - message = message.replace("<", "\\<") + ) message = message.replace("<", "\\<") if ( ((channelconf.permitFormatting ?: ChannelSettings.global.permitFormatting) != false) && LoggerConfiguration.features.contains(Feature.FORMATTING) - ) - format.addFeature(Feature.FORMATTING) + ) format.addFeature(Feature.FORMATTING) // Set message format.message = message diff --git a/logging/src/main/kotlin/de/staropensource/engine/logging/implementation/SOSLSv2FormatBuilder.kt b/logging/src/main/kotlin/de/staropensource/engine/logging/implementation/SOSLSv2FormatBuilder.kt index 551e102..da6df9f 100644 --- a/logging/src/main/kotlin/de/staropensource/engine/logging/implementation/SOSLSv2FormatBuilder.kt +++ b/logging/src/main/kotlin/de/staropensource/engine/logging/implementation/SOSLSv2FormatBuilder.kt @@ -91,20 +91,20 @@ class SOSLSv2FormatBuilder(call: Call) : FormatBuilder(call) { format.append("[") if (enabledFeatures.contains(Feature.DATE)) format - .append(datetime.dayOfMonth) + .append("%02d".format(datetime.dayOfMonth.toString())) .append(".") - .append(datetime.monthNumber) + .append("%02d".format(datetime.monthNumber)) .append(".") - .append(datetime.year) + .append("%04d".format(datetime.year)) if (enabledFeatures.contains(Feature.DATE) && enabledFeatures.contains(Feature.TIME)) format.append(" ") if (enabledFeatures.contains(Feature.TIME)) format - .append(datetime.hour) + .append("%02d".format(datetime.hour)) .append(":") - .append(datetime.minute) + .append("%02d".format(datetime.minute)) .append(":") - .append(datetime.second) + .append("%02d".format(datetime.second)) if (enabledFeatures.contains(Feature.DATE) || enabledFeatures.contains(Feature.TIME)) format.append("] ") }