mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-19 13:46:17 +00:00
logging: implement lazy sprinting (#8898)
shout out to @joeabbey for the inspiration. This makes the lazy functions internal by default to prevent potential misuse by external callers. Should backport cleanly into 0.36 and I'll handle a messy merge into 0.35
This commit is contained in:
+2
-6
@@ -55,9 +55,7 @@ func NewDefaultLogger(format, level string) (Logger, error) {
|
||||
// make the writer thread-safe
|
||||
logWriter = newSyncWriter(logWriter)
|
||||
|
||||
return &defaultLogger{
|
||||
Logger: zerolog.New(logWriter).Level(logLevel).With().Timestamp().Logger(),
|
||||
}, nil
|
||||
return &defaultLogger{Logger: zerolog.New(logWriter).Level(logLevel).With().Timestamp().Logger()}, nil
|
||||
}
|
||||
|
||||
func (l defaultLogger) Info(msg string, keyVals ...interface{}) {
|
||||
@@ -73,9 +71,7 @@ func (l defaultLogger) Debug(msg string, keyVals ...interface{}) {
|
||||
}
|
||||
|
||||
func (l defaultLogger) With(keyVals ...interface{}) Logger {
|
||||
return &defaultLogger{
|
||||
Logger: l.Logger.With().Fields(keyVals).Logger(),
|
||||
}
|
||||
return &defaultLogger{Logger: l.Logger.With().Fields(keyVals).Logger()}
|
||||
}
|
||||
|
||||
// OverrideWithNewLogger replaces an existing logger's internal with
|
||||
|
||||
Reference in New Issue
Block a user