优化日志输出格式

This commit is contained in:
duanhf2012
2023-09-01 17:44:59 +08:00
parent fa8cbfb40e
commit 2d1bee4dea
2 changed files with 14 additions and 28 deletions

View File

@@ -489,23 +489,8 @@ func (logger *Logger) formatHeader(buf *Buffer,level slog.Level,calldepth int) {
file = filepath.Base(file)
buf.AppendString("time=\"")
year, month, day := t.Date()
buf.AppendInt(int64(year))
buf.AppendByte('/')
buf.AppendInt(int64(month))
buf.AppendByte('/')
buf.AppendInt(int64(day))
buf.AppendByte(' ')
hour, min, sec := t.Clock()
buf.AppendInt(int64(hour))
buf.AppendByte(':')
buf.AppendInt(int64(min))
buf.AppendByte(':')
buf.AppendInt(int64(sec))
buf.AppendString(t.Format("2006/01/02 15:04:05"))
buf.AppendString("\"")
logger.sBuff.AppendString(" level=")
logger.sBuff.AppendString(getStrLevel(level))
logger.sBuff.AppendString(" source=")