修改日志格式.
Signed-off-by: rick.chan <cy@haoan119.com>
This commit is contained in:
parent
7bcab53f68
commit
d697c0a470
21
simplelog.go
21
simplelog.go
@ -228,17 +228,25 @@ func (l *SimpleLog) Output(callDepth int, level int, format string, v ...interfa
|
|||||||
|
|
||||||
buf := l.popBuf()
|
buf := l.popBuf()
|
||||||
|
|
||||||
if l.flag&Llevel > 0 {
|
if (l.flag&Llevel > 0) || (l.flag&Ltime > 0) || (l.flag&Lfile > 0) {
|
||||||
buf = append(buf, '[')
|
buf = append(buf, '[')
|
||||||
|
}
|
||||||
|
|
||||||
|
if l.flag&Llevel > 0 {
|
||||||
buf = append(buf, LevelName[level]...)
|
buf = append(buf, LevelName[level]...)
|
||||||
buf = append(buf, "] "...)
|
}
|
||||||
|
|
||||||
|
if (l.flag&Llevel > 0) && (l.flag&Ltime > 0) {
|
||||||
|
buf = append(buf, " | "...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if l.flag&Ltime > 0 {
|
if l.flag&Ltime > 0 {
|
||||||
now := time.Now().Format(TimeFormat)
|
now := time.Now().Format(TimeFormat)
|
||||||
buf = append(buf, '[')
|
|
||||||
buf = append(buf, now...)
|
buf = append(buf, now...)
|
||||||
buf = append(buf, "] "...)
|
}
|
||||||
|
|
||||||
|
if (l.flag&Ltime > 0) && (l.flag&Lfile > 0) {
|
||||||
|
buf = append(buf, " | "...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if l.flag&Lfile > 0 {
|
if l.flag&Lfile > 0 {
|
||||||
@ -259,7 +267,10 @@ func (l *SimpleLog) Output(callDepth int, level int, format string, v ...interfa
|
|||||||
buf = append(buf, ':')
|
buf = append(buf, ':')
|
||||||
|
|
||||||
buf = strconv.AppendInt(buf, int64(line), 10)
|
buf = strconv.AppendInt(buf, int64(line), 10)
|
||||||
buf = append(buf, ' ')
|
|
||||||
|
if (l.flag&Llevel > 0) || (l.flag&Ltime > 0) || (l.flag&Lfile > 0) {
|
||||||
|
buf = append(buf, "] "...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = append(buf, s...)
|
buf = append(buf, s...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user