fix log level

This commit is contained in:
王厚伟 2021-01-03 17:52:48 +08:00
parent 65f8590910
commit 4b2bd716b6
2 changed files with 3 additions and 3 deletions

View File

@ -69,8 +69,8 @@ func (p *PatternLogFormatter) ToString(lm *LogMsg) string {
'm': lm.Msg,
'n': strconv.Itoa(lm.LineNumber),
'l': strconv.Itoa(lm.Level),
't': levelPrefix[lm.Level-1],
'T': levelNames[lm.Level-1],
't': levelPrefix[lm.Level],
'T': levelNames[lm.Level],
'F': lm.FilePath,
}
_, m['f'] = path.Split(lm.FilePath)

View File

@ -88,7 +88,7 @@ func TestPatternLogFormatter(t *testing.T) {
}
got := tes.ToString(lm)
want := lm.FilePath + ":" + strconv.Itoa(lm.LineNumber) + "|" +
when.Format(tes.WhenFormat) + levelPrefix[lm.Level-1] + ">> " + lm.Msg
when.Format(tes.WhenFormat) + levelPrefix[lm.Level] + ">> " + lm.Msg
if got != want {
t.Errorf("want %s, got %s", want, got)
}