Merge pull request #4406 from wangle201210/fix/log-format

fix log level
This commit is contained in:
Ming Deng 2021-01-03 19:24:01 +08:00 committed by GitHub
commit cb330fbb99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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, 'm': lm.Msg,
'n': strconv.Itoa(lm.LineNumber), 'n': strconv.Itoa(lm.LineNumber),
'l': strconv.Itoa(lm.Level), 'l': strconv.Itoa(lm.Level),
't': levelPrefix[lm.Level-1], 't': levelPrefix[lm.Level],
'T': levelNames[lm.Level-1], 'T': levelNames[lm.Level],
'F': lm.FilePath, 'F': lm.FilePath,
} }
_, m['f'] = path.Split(lm.FilePath) _, m['f'] = path.Split(lm.FilePath)

View File

@ -88,7 +88,7 @@ func TestPatternLogFormatter(t *testing.T) {
} }
got := tes.ToString(lm) got := tes.ToString(lm)
want := lm.FilePath + ":" + strconv.Itoa(lm.LineNumber) + "|" + 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 { if got != want {
t.Errorf("want %s, got %s", want, got) t.Errorf("want %s, got %s", want, got)
} }