github.com/mgoltzsche/ctnr@v0.7.1-alpha/pkg/log/log.go (about) 1 package log 2 3 type Loggers struct { 4 Error FieldLogger 5 Warn FieldLogger 6 Info FieldLogger 7 Debug FieldLogger 8 } 9 10 func (l Loggers) WithField(name string, value interface{}) Loggers { 11 return Loggers{ 12 Error: l.Error.WithField(name, value), 13 Warn: l.Warn.WithField(name, value), 14 Info: l.Info.WithField(name, value), 15 Debug: l.Debug.WithField(name, value), 16 } 17 } 18 19 type Logger interface { 20 Printf(string, ...interface{}) 21 Println(...interface{}) 22 } 23 24 type FieldLogger interface { 25 Logger 26 WithField(name string, value interface{}) FieldLogger 27 } 28 29 type nopLogger struct{} 30 31 func NewNopLogger() FieldLogger { 32 return &nopLogger{} 33 } 34 35 func (l *nopLogger) Printf(string, ...interface{}) {} 36 func (l *nopLogger) Println(...interface{}) {} 37 func (l *nopLogger) WithField(string, interface{}) FieldLogger { return l }