1 package log 2 3 import ( 4 "github.com/go-kit/log" 5 ) 6 7 // Logger is the fundamental interface for all log operations. Log creates a 8 // log event from keyvals, a variadic sequence of alternating keys and values. 9 // Implementations must be safe for concurrent use by multiple goroutines. In 10 // particular, any implementation of Logger that appends to keyvals or 11 // modifies or retains any of its elements must make a copy first. 12 type Logger = log.Logger 13 14 // ErrMissingValue is appended to keyvals slices with odd length to substitute 15 // the missing value. 16 var ErrMissingValue = log.ErrMissingValue 17 18 // With returns a new contextual logger with keyvals prepended to those passed 19 // to calls to Log. If logger is also a contextual logger created by With, 20 // WithPrefix, or WithSuffix, keyvals is appended to the existing context. 21 // 22 // The returned Logger replaces all value elements (odd indexes) containing a 23 // Valuer with their generated value for each call to its Log method. 24 func With(logger Logger, keyvals ...interface{}) Logger { 25 return log.With(logger, keyvals...) 26 } 27 28 // WithPrefix returns a new contextual logger with keyvals prepended to those 29 // passed to calls to Log. If logger is also a contextual logger created by 30 // With, WithPrefix, or WithSuffix, keyvals is prepended to the existing context. 31 // 32 // The returned Logger replaces all value elements (odd indexes) containing a 33 // Valuer with their generated value for each call to its Log method. 34 func WithPrefix(logger Logger, keyvals ...interface{}) Logger { 35 return log.WithPrefix(logger, keyvals...) 36 } 37 38 // WithSuffix returns a new contextual logger with keyvals appended to those 39 // passed to calls to Log. If logger is also a contextual logger created by 40 // With, WithPrefix, or WithSuffix, keyvals is appended to the existing context. 41 // 42 // The returned Logger replaces all value elements (odd indexes) containing a 43 // Valuer with their generated value for each call to its Log method. 44 func WithSuffix(logger Logger, keyvals ...interface{}) Logger { 45 return log.WithSuffix(logger, keyvals...) 46 } 47 48 // LoggerFunc is an adapter to allow use of ordinary functions as Loggers. If 49 // f is a function with the appropriate signature, LoggerFunc(f) is a Logger 50 // object that calls f. 51 type LoggerFunc = log.LoggerFunc 52