mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-29 00:32:14 +00:00
See https://github.com/go-kit/kit/issues/164 for discussion of why kitlog returns an error. ``` Package log is designed to be used for more than simple application info/warning/error logging; it's suitable for log-structured data in an e.g. Lambda architecture, where each invocation is important. I agree with you that if we were doing only application logging the error would be more noise than signal. But the scope of the package is larger than that. ``` Since we are doing only application logging and we're not checking errors, it is safe to get rid them.
31 lines
727 B
Go
31 lines
727 B
Go
package log_test
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"testing"
|
|
|
|
"github.com/tendermint/tmlibs/log"
|
|
)
|
|
|
|
func BenchmarkTMLoggerSimple(b *testing.B) {
|
|
benchmarkRunner(b, log.NewTMLogger(ioutil.Discard), baseInfoMessage)
|
|
}
|
|
|
|
func BenchmarkTMLoggerContextual(b *testing.B) {
|
|
benchmarkRunner(b, log.NewTMLogger(ioutil.Discard), withInfoMessage)
|
|
}
|
|
|
|
func benchmarkRunner(b *testing.B, logger log.Logger, f func(log.Logger)) {
|
|
lc := logger.With("common_key", "common_value")
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
f(lc)
|
|
}
|
|
}
|
|
|
|
var (
|
|
baseInfoMessage = func(logger log.Logger) { logger.Info("foo_message", "foo_key", "foo_value") }
|
|
withInfoMessage = func(logger log.Logger) { logger.With("a", "b").Info("c", "d", "f") }
|
|
)
|