diff --git a/log/default.go b/log/default.go index d8014489..a8aaff87 100644 --- a/log/default.go +++ b/log/default.go @@ -52,7 +52,7 @@ func (l *simpleLogger) Log(ctx context.Context, level Level, args []any) { if level > l.level { return } - message := l.formatter.Format(ctx, level, l.tag, F.ToString(args...), time.Now()) + "\n" + message := l.formatter.Format(ctx, level, l.tag, F.ToString(args...), time.Now()) if level == LevelPanic { panic(message) } diff --git a/log/format.go b/log/format.go index ef69d821..96e0364b 100644 --- a/log/format.go +++ b/log/format.go @@ -75,7 +75,10 @@ func (f Formatter) Format(ctx context.Context, level Level, tag string, message default: message = levelString + "[" + xd(int(timestamp.Sub(f.BaseTime)/time.Second), 4) + "] " + message } - return message + "\n" + if message[len(message)-1] != '\n' { + message += "\n" + } + return message } func (f Formatter) FormatWithSimple(ctx context.Context, level Level, tag string, message string, timestamp time.Time) (string, string) { @@ -137,7 +140,10 @@ func (f Formatter) FormatWithSimple(ctx context.Context, level Level, tag string default: message = levelString + "[" + xd(int(timestamp.Sub(f.BaseTime)/time.Second), 4) + "] " + message } - return message + "\n", messageSimple + if message[len(message)-1] != '\n' { + message += "\n" + } + return message, messageSimple } func xd(value int, x int) string {