From cb891388425bba3a9fc4194bd782c4a69584e42f Mon Sep 17 00:00:00 2001 From: velvettear Date: Thu, 2 Nov 2023 15:20:09 +0100 Subject: [PATCH] trim log message if 'extras' or 'time diff' is empty --- print.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/print.go b/print.go index 8dfefc0..18120f6 100644 --- a/print.go +++ b/print.go @@ -69,12 +69,14 @@ func print(logLevel logLevel, message string, timestamp int64, extras ...string) formatted = strings.ReplaceAll(formatted, PLACEHOLDER_MESSAGE, message) if len(extras) == 0 { formatted = strings.ReplaceAll(formatted, GetExtrasFormat(), "") + formatted = strings.TrimSpace(formatted) } else { format := GetExtrasFormat() formatted = strings.ReplaceAll(formatted, format, strings.ReplaceAll(format, PLACEHOLDER_EXTRAS, strings.Join(extras, GetExtrasSeparator()))) } if timestamp <= 0 { formatted = strings.ReplaceAll(formatted, GetTimediffFormat(), "") + formatted = strings.TrimSpace(formatted) } else { format := GetTimediffFormat() formatted = strings.ReplaceAll(formatted, format, strings.ReplaceAll(format, PLACEHOLDER_TIMEDIFF, strconv.FormatInt(now.UnixMilli()-timestamp, 10)+"ms"))