func BenchmarkLogger_large(b *testing.B) { l := &log.Logger{ Handler: discard.New(), Level: log.InfoLevel, } err := fmt.Errorf("boom") for i := 0; i < b.N; i++ { l.WithFields(log.Fields{ "file": "sloth.png", "type": "image/png", "size": 1 << 20, }). WithFields(log.Fields{ "some": "more", "data": "here", "whatever": "blah blah", "more": "stuff", "context": "such useful", "much": "fun", }). WithError(err).Error("upload failed") } }
func BenchmarkLogger_small(b *testing.B) { l := &log.Logger{ Handler: discard.New(), Level: log.InfoLevel, } for i := 0; i < b.N; i++ { l.Info("login") } }
func BenchmarkLogger_medium(b *testing.B) { l := &log.Logger{ Handler: discard.New(), Level: log.InfoLevel, } for i := 0; i < b.N; i++ { l.WithFields(log.Fields{ "file": "sloth.png", "type": "image/png", "size": 1 << 20, }).Info("upload") } }
func init() { log.SetHandler(discard.New()) }