Fix padding of dates and times in log format

This commit is contained in:
JeremyStar™ 2024-12-15 01:06:05 +01:00
parent ef692a31d5
commit e76b0e72ff
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
2 changed files with 8 additions and 10 deletions

View file

@ -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

View file

@ -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("] ")
}