1 package log 2 3 import ( 4 "time" 5 6 "github.com/go-kit/log" 7 ) 8 9 // A Valuer generates a log value. When passed to With, WithPrefix, or 10 // WithSuffix in a value element (odd indexes), it represents a dynamic 11 // value which is re-evaluated with each log event. 12 type Valuer = log.Valuer 13 14 // Timestamp returns a timestamp Valuer. It invokes the t function to get the 15 // time; unless you are doing something tricky, pass time.Now. 16 // 17 // Most users will want to use DefaultTimestamp or DefaultTimestampUTC, which 18 // are TimestampFormats that use the RFC3339Nano format. 19 func Timestamp(t func() time.Time) Valuer { 20 return log.Timestamp(t) 21 } 22 23 // TimestampFormat returns a timestamp Valuer with a custom time format. It 24 // invokes the t function to get the time to format; unless you are doing 25 // something tricky, pass time.Now. The layout string is passed to 26 // Time.Format. 27 // 28 // Most users will want to use DefaultTimestamp or DefaultTimestampUTC, which 29 // are TimestampFormats that use the RFC3339Nano format. 30 func TimestampFormat(t func() time.Time, layout string) Valuer { 31 return log.TimestampFormat(t, layout) 32 } 33 34 // Caller returns a Valuer that returns a file and line from a specified depth 35 // in the callstack. Users will probably want to use DefaultCaller. 36 func Caller(depth int) Valuer { 37 return log.Caller(depth) 38 } 39 40 var ( 41 // DefaultTimestamp is a Valuer that returns the current wallclock time, 42 // respecting time zones, when bound. 43 DefaultTimestamp = log.DefaultTimestamp 44 45 // DefaultTimestampUTC is a Valuer that returns the current time in UTC 46 // when bound. 47 DefaultTimestampUTC = log.DefaultTimestampUTC 48 49 // DefaultCaller is a Valuer that returns the file and line where the Log 50 // method was invoked. It can only be used with log.With. 51 DefaultCaller = log.DefaultCaller 52 ) 53