mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 00:21:30 +00:00
Fix log format
This commit is contained in:
parent
e531e89b4b
commit
7bc7b72c61
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue