Skip to content

Commit

Permalink
fix BUG for:level format (#24)
Browse files Browse the repository at this point in the history
* fix BUG for:level format
per level must own self formatter

* fix BUG for:level format
per level must own self formatter
  • Loading branch information
Fly-Playgroud authored Jun 24, 2023
1 parent fa0b1af commit 74c7c01
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var logHijacker = func(ctx *pio.Ctx) {
defer logger.mu.Unlock()

w := logger.getOutput(l.Level)
if f := logger.getFormatter(); f != nil {
if f := logger.getFormatter(l.Level); f != nil {
if f.Format(w, l) {
ctx.Store(nil, pio.ErrHandled)
return
Expand Down Expand Up @@ -266,8 +266,8 @@ func (l *Logger) SetLevelFormat(levelName string, formatter string, opts ...inte
return l
}

func (l *Logger) getFormatter() Formatter {
f, ok := l.LevelFormatter[l.Level]
func (l *Logger) getFormatter(level Level) Formatter {
f, ok := l.LevelFormatter[level]
if !ok {
f = l.formatter
}
Expand Down

0 comments on commit 74c7c01

Please sign in to comment.