Fix write log timestamp

This commit is contained in:
世界 2022-08-31 23:35:43 +08:00
parent f5f5cb023c
commit a44cb745d9
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -71,7 +71,7 @@ func (f Formatter) Format(ctx context.Context, level Level, tag string, message
case f.DisableTimestamp: case f.DisableTimestamp:
message = levelString + " " + message message = levelString + " " + message
case f.FullTimestamp: case f.FullTimestamp:
message = F.ToString(int(timestamp.Sub(f.BaseTime)/time.Second)) + " " + levelString + " " + message message = timestamp.Format(f.TimestampFormat) + " " + levelString + " " + message
default: default:
message = levelString + "[" + xd(int(timestamp.Sub(f.BaseTime)/time.Second), 4) + "] " + message message = levelString + "[" + xd(int(timestamp.Sub(f.BaseTime)/time.Second), 4) + "] " + message
} }
@ -136,7 +136,7 @@ func (f Formatter) FormatWithSimple(ctx context.Context, level Level, tag string
case f.DisableTimestamp: case f.DisableTimestamp:
message = levelString + " " + message message = levelString + " " + message
case f.FullTimestamp: case f.FullTimestamp:
message = F.ToString(int(timestamp.Sub(f.BaseTime)/time.Second)) + " " + levelString + " " + message message = timestamp.Format(f.TimestampFormat) + " " + levelString + " " + message
default: default:
message = levelString + "[" + xd(int(timestamp.Sub(f.BaseTime)/time.Second), 4) + "] " + message message = levelString + "[" + xd(int(timestamp.Sub(f.BaseTime)/time.Second), 4) + "] " + message
} }