trim log message if 'extras' or 'time diff' is empty
This commit is contained in:
parent
0b5381f82e
commit
cb89138842
1 changed files with 2 additions and 0 deletions
2
print.go
2
print.go
|
@ -69,12 +69,14 @@ func print(logLevel logLevel, message string, timestamp int64, extras ...string)
|
||||||
formatted = strings.ReplaceAll(formatted, PLACEHOLDER_MESSAGE, message)
|
formatted = strings.ReplaceAll(formatted, PLACEHOLDER_MESSAGE, message)
|
||||||
if len(extras) == 0 {
|
if len(extras) == 0 {
|
||||||
formatted = strings.ReplaceAll(formatted, GetExtrasFormat(), "")
|
formatted = strings.ReplaceAll(formatted, GetExtrasFormat(), "")
|
||||||
|
formatted = strings.TrimSpace(formatted)
|
||||||
} else {
|
} else {
|
||||||
format := GetExtrasFormat()
|
format := GetExtrasFormat()
|
||||||
formatted = strings.ReplaceAll(formatted, format, strings.ReplaceAll(format, PLACEHOLDER_EXTRAS, strings.Join(extras, GetExtrasSeparator())))
|
formatted = strings.ReplaceAll(formatted, format, strings.ReplaceAll(format, PLACEHOLDER_EXTRAS, strings.Join(extras, GetExtrasSeparator())))
|
||||||
}
|
}
|
||||||
if timestamp <= 0 {
|
if timestamp <= 0 {
|
||||||
formatted = strings.ReplaceAll(formatted, GetTimediffFormat(), "")
|
formatted = strings.ReplaceAll(formatted, GetTimediffFormat(), "")
|
||||||
|
formatted = strings.TrimSpace(formatted)
|
||||||
} else {
|
} else {
|
||||||
format := GetTimediffFormat()
|
format := GetTimediffFormat()
|
||||||
formatted = strings.ReplaceAll(formatted, format, strings.ReplaceAll(format, PLACEHOLDER_TIMEDIFF, strconv.FormatInt(now.UnixMilli()-timestamp, 10)+"ms"))
|
formatted = strings.ReplaceAll(formatted, format, strings.ReplaceAll(format, PLACEHOLDER_TIMEDIFF, strconv.FormatInt(now.UnixMilli()-timestamp, 10)+"ms"))
|
||||||
|
|
Loading…
Reference in a new issue