Skip to content

Commit

Permalink
Skip low level message to avoid clock_gettime
Browse files Browse the repository at this point in the history
  • Loading branch information
Laisky committed Jan 25, 2019
1 parent 82e3b47 commit 6bd4aaf
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,20 @@ func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {

// Create basic checked entry thru the core; this will be non-nil if the
// log message will actually be written somewhere.
ent := zapcore.Entry{
LoggerName: log.name,
Time: time.Now(),
Level: lvl,
Message: msg,
var ent zapcore.Entry
if log.core.Enabled(lvl) {
ent = zapcore.Entry{
LoggerName: log.name,
Time: time.Now(),
Level: lvl,
Message: msg,
}
} else {
ent = zapcore.Entry{
Level: lvl,
}
}

ce := log.core.Check(ent, nil)
willWrite := ce != nil

Expand Down

0 comments on commit 6bd4aaf

Please sign in to comment.