Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Debugln(args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalln(args ...interface{})
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Infoln(args ...interface{})
- func Panic(args ...interface{})
- func Panicf(format string, args ...interface{})
- func Panicln(args ...interface{})
- func Print(args ...interface{})
- func Printf(format string, args ...interface{})
- func Println(args ...interface{})
- func SetGlobalLevel(l Level)
- func ToStd(logger *Logger) *stdLogger
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func Warnln(args ...interface{})
- type Context
- func (c Context) AnErr(key string, err error) Context
- func (c Context) Array(key string, arr zerolog.LogArrayMarshaler) Context
- func (c Context) Bool(key string, b bool) Context
- func (c Context) Bools(key string, b []bool) Context
- func (c Context) Bytes(key string, val []byte) Context
- func (c Context) Caller() Context
- func (c Context) CallerWithSkipFrameCount(skipFrameCount int) Context
- func (c Context) Dict(key string, dict *zerolog.Event) Context
- func (c Context) Dur(key string, d time.Duration) Context
- func (c Context) Durs(key string, d []time.Duration) Context
- func (c Context) EmbedObject(obj zerolog.LogObjectMarshaler) Context
- func (c Context) Err(err error) Context
- func (c Context) Errs(key string, errs []error) Context
- func (c Context) Fields(fields interface{}) Context
- func (c Context) Float32(key string, f float32) Context
- func (c Context) Float64(key string, f float64) Context
- func (c Context) Floats32(key string, f []float32) Context
- func (c Context) Floats64(key string, f []float64) Context
- func (c Context) Hex(key string, val []byte) Context
- func (c Context) IPAddr(key string, ip net.IP) Context
- func (c Context) IPPrefix(key string, pfx net.IPNet) Context
- func (c Context) Int(key string, i int) Context
- func (c Context) Int8(key string, i int8) Context
- func (c Context) Int16(key string, i int16) Context
- func (c Context) Int32(key string, i int32) Context
- func (c Context) Int64(key string, i int64) Context
- func (c Context) Interface(key string, i interface{}) Context
- func (c Context) Ints(key string, i []int) Context
- func (c Context) Ints8(key string, i []int8) Context
- func (c Context) Ints16(key string, i []int16) Context
- func (c Context) Ints32(key string, i []int32) Context
- func (c Context) Ints64(key string, i []int64) Context
- func (c Context) Logger() Logger
- func (c Context) MACAddr(key string, ha net.HardwareAddr) Context
- func (c Context) Object(key string, obj zerolog.LogObjectMarshaler) Context
- func (c Context) RawJSON(key string, b []byte) Context
- func (c Context) Stack() Context
- func (c Context) Str(key, val string) Context
- func (c Context) Stringer(key string, val fmt.Stringer) Context
- func (c Context) Strs(key string, vals []string) Context
- func (c Context) Time(key string, t time.Time) Context
- func (c Context) Times(key string, t []time.Time) Context
- func (c Context) Timestamp() Context
- func (c Context) Uint(key string, i uint) Context
- func (c Context) Uint8(key string, i uint8) Context
- func (c Context) Uint16(key string, i uint16) Context
- func (c Context) Uint32(key string, i uint32) Context
- func (c Context) Uint64(key string, i uint64) Context
- func (c Context) Uints(key string, i []uint) Context
- func (c Context) Uints8(key string, i []uint8) Context
- func (c Context) Uints16(key string, i []uint16) Context
- func (c Context) Uints32(key string, i []uint32) Context
- func (c Context) Uints64(key string, i []uint64) Context
- type Event
- func (e *Event) AnErr(key string, err error) *Event
- func (e *Event) Any(key string, i interface{}) *Event
- func (e *Event) Array(key string, arr zerolog.LogArrayMarshaler) *Event
- func (e *Event) Bool(key string, b bool) *Event
- func (e *Event) Bools(key string, b []bool) *Event
- func (e *Event) Bytes(key string, val []byte) *Event
- func (e *Event) Caller(skip ...int) *Event
- func (e *Event) CallerSkipFrame(skip int) *Event
- func (e *Event) Dict(key string, dict *Event) *Event
- func (e *Event) Discard() *Event
- func (e *Event) Dur(key string, d time.Duration) *Event
- func (e *Event) Durs(key string, d []time.Duration) *Event
- func (e *Event) EmbedObject(obj zerolog.LogObjectMarshaler) *Event
- func (e *Event) Err(err error) *Event
- func (e *Event) Errs(key string, errs []error) *Event
- func (e *Event) Fields(fields interface{}) *Event
- func (e *Event) Float32(key string, f float32) *Event
- func (e *Event) Float64(key string, f float64) *Event
- func (e *Event) Floats32(key string, f []float32) *Event
- func (e *Event) Floats64(key string, f []float64) *Event
- func (e *Event) Func(f func(e *Event)) *Event
- func (e *Event) Hex(key string, val []byte) *Event
- func (e *Event) IPAddr(key string, ip net.IP) *Event
- func (e *Event) IPPrefix(key string, pfx net.IPNet) *Event
- func (e *Event) Int(key string, i int) *Event
- func (e *Event) Int8(key string, i int8) *Event
- func (e *Event) Int16(key string, i int16) *Event
- func (e *Event) Int32(key string, i int32) *Event
- func (e *Event) Int64(key string, i int64) *Event
- func (e *Event) Interface(key string, i interface{}) *Event
- func (e *Event) Ints(key string, i []int) *Event
- func (e *Event) Ints8(key string, i []int8) *Event
- func (e *Event) Ints16(key string, i []int16) *Event
- func (e *Event) Ints32(key string, i []int32) *Event
- func (e *Event) Ints64(key string, i []int64) *Event
- func (e *Event) MACAddr(key string, ha net.HardwareAddr) *Event
- func (e *Event) Msg(msg string)
- func (e *Event) Msgf(format string, v ...interface{})
- func (e *Event) Object(key string, obj zerolog.LogObjectMarshaler) *Event
- func (e *Event) RawCBOR(key string, b []byte) *Event
- func (e *Event) RawJSON(key string, b []byte) *Event
- func (e *Event) Send()
- func (e *Event) Stack() *Event
- func (e *Event) Str(key, val string) *Event
- func (e *Event) Stringer(key string, val fmt.Stringer) *Event
- func (e *Event) Stringers(key string, vals []fmt.Stringer) *Event
- func (e *Event) Strs(key string, vals []string) *Event
- func (e *Event) Time(key string, t time.Time) *Event
- func (e *Event) TimeDiff(key string, t time.Time, start time.Time) *Event
- func (e *Event) Times(key string, t []time.Time) *Event
- func (e *Event) Timestamp() *Event
- func (e *Event) Type(key string, val interface{}) *Event
- func (e *Event) Uint(key string, i uint) *Event
- func (e *Event) Uint8(key string, i uint8) *Event
- func (e *Event) Uint16(key string, i uint16) *Event
- func (e *Event) Uint32(key string, i uint32) *Event
- func (e *Event) Uint64(key string, i uint64) *Event
- func (e *Event) Uints(key string, i []uint) *Event
- func (e *Event) Uints8(key string, i []uint8) *Event
- func (e *Event) Uints16(key string, i []uint16) *Event
- func (e *Event) Uints32(key string, i []uint32) *Event
- func (e *Event) Uints64(key string, i []uint64) *Event
- type Level
- type Logger
- func (l *Logger) Debug() *Event
- func (l *Logger) Err(err error) *Event
- func (l *Logger) Error() *Event
- func (l *Logger) Fatal() *Event
- func (l Logger) GetLevel() Level
- func (l Logger) Hook(h zerolog.Hook) Logger
- func (l *Logger) Info() *Event
- func (l Logger) Level(lvl zerolog.Level) Logger
- func (l *Logger) Log() *Event
- func (l Logger) Output(w io.Writer) Logger
- func (l *Logger) Panic() *Event
- func (logger *Logger) PointerToStd() *stdLogger
- func (l *Logger) Print(v ...interface{})
- func (l *Logger) Printf(format string, v ...interface{})
- func (l Logger) Sample(s zerolog.Sampler) Logger
- func (logger Logger) ToStd() stdLogger
- func (l *Logger) Trace() *Event
- func (l *Logger) UpdateContext(update func(c Context) Context)
- func (l *Logger) Warn() *Event
- func (l Logger) With() Context
- func (l Logger) WithContext(ctx context.Context) context.Context
- func (l *Logger) WithLevel(level zerolog.Level) *Event
- func (l Logger) Write(p []byte) (n int, err error)
Constants ¶
const ( // DebugLevel defines debug log level. DebugLevel = Level(zerolog.DebugLevel) // InfoLevel defines info log level. InfoLevel = Level(zerolog.InfoLevel) // WarnLevel defines warn log level. WarnLevel = Level(zerolog.WarnLevel) // ErrorLevel defines error log level. ErrorLevel = Level(zerolog.ErrorLevel) // FatalLevel defines fatal log level. FatalLevel = Level(zerolog.FatalLevel) // PanicLevel defines panic log level. PanicLevel = Level(zerolog.PanicLevel) // NoLevel defines an absent log level. NoLevel = Level(zerolog.NoLevel) // Disabled disables the logger. Disabled = Level(zerolog.Disabled) // TraceLevel defines trace log level. TraceLevel = Level(zerolog.TraceLevel) )
Variables ¶
var StdLogger = New(os.Stderr)
Logger is the global logger.
Functions ¶
func SetGlobalLevel ¶
func SetGlobalLevel(l Level)
Types ¶
type Context ¶
func (Context) Array ¶
func (c Context) Array(key string, arr zerolog.LogArrayMarshaler) Context
Array adds the field key with an array to the event context. Use zerolog.Arr() to create the array or pass a type that implement the LogArrayMarshaler interface.
func (Context) CallerWithSkipFrameCount ¶
func (Context) EmbedObject ¶
func (c Context) EmbedObject(obj zerolog.LogObjectMarshaler) Context
EmbedObject marshals and Embeds an object that implement the LogObjectMarshaler interface.
func (Context) Errs ¶
Errs adds the field key with errs as an array of serialized errors to the logger context.
func (Context) Fields ¶
Fields is a helper function to use a map or slice to set fields using type assertion. Only map[string]interface{} and []interface{} are accepted. []interface{} must alternate string keys and arbitrary values, and extraneous ones are ignored.
func (Context) MACAddr ¶
func (c Context) MACAddr(key string, ha net.HardwareAddr) Context
MACAddr adds MAC address to the context
func (Context) Object ¶
func (c Context) Object(key string, obj zerolog.LogObjectMarshaler) Context
Object marshals an object that implement the LogObjectMarshaler interface.
func (Context) RawJSON ¶
RawJSON adds already encoded JSON to context.
No sanity check is performed on b; it must not contain carriage returns and be valid JSON.
func (Context) Stringer ¶
Stringer adds the field key with val.String() (or null if val is nil) to the logger context.
func (Context) Time ¶
Time adds the field key with t formated as string using zerolog.TimeFieldFormat.
func (Context) Times ¶
Times adds the field key with t formated as string using zerolog.TimeFieldFormat.
type Event ¶
func (*Event) AnErr ¶
AnErr adds the field key with serialized err to the *Event context. If err is nil, no field is added.
func (*Event) CallerSkipFrame ¶
func (*Event) Dict ¶
Dict adds the field key with a dict to the event context. Use zerolog.Dict() to create the dictionary.
func (*Event) Dur ¶
Dur adds the field key with duration d stored as zerolog.DurationFieldUnit. If zerolog.DurationFieldInteger is true, durations are rendered as integer instead of float.
func (*Event) Durs ¶
Durs adds the field key with duration d stored as zerolog.DurationFieldUnit. If zerolog.DurationFieldInteger is true, durations are rendered as integer instead of float.
func (*Event) EmbedObject ¶
func (e *Event) EmbedObject(obj zerolog.LogObjectMarshaler) *Event
EmbedObject marshals an object that implement the LogObjectMarshaler interface.
func (*Event) Errs ¶
Errs adds the field key with errs as an array of serialized errors to the *Event context.
func (*Event) MACAddr ¶
func (e *Event) MACAddr(key string, ha net.HardwareAddr) *Event
MACAddr adds MAC address to the event
func (*Event) Object ¶
func (e *Event) Object(key string, obj zerolog.LogObjectMarshaler) *Event
Object marshals an object that implement the LogObjectMarshaler interface.
func (*Event) RawCBOR ¶
RawCBOR adds already encoded CBOR to the log line under key.
No sanity check is performed on b Note: The full featureset of CBOR is supported as data will not be mapped to json but stored as data-url
func (*Event) Stack ¶
Stack enables stack trace printing for the error passed to Err().
ErrorStackMarshaler must be set for this method to do something.
func (*Event) Stringer ¶
Stringer adds the field key with val.String() (or null if val is nil) to the *Event context.
func (*Event) Time ¶
Time adds the field key with t formatted as string using zerolog.TimeFieldFormat.
func (*Event) TimeDiff ¶
TimeDiff adds the field key with positive duration between time t and start. If time t is not greater than start, duration will be 0. Duration format follows the same principle as Dur().
func (*Event) Times ¶
Times adds the field key with t formatted as string using zerolog.TimeFieldFormat.
func (*Event) Timestamp ¶
Timestamp adds the current local time as UNIX timestamp to the *Event context with the "time" key. To customize the key name, change zerolog.TimestampFieldName.
NOTE: It won't dedupe the "time" key if the *Event (or *Context) has one already.
type Logger ¶
func (*Logger) Debug ¶
Debug starts a new message with debug level.
You must call Msg on the returned event in order to send the event.
func (*Logger) Info ¶
Info starts a new message with info level.
You must call Msg on the returned event in order to send the event.
func (*Logger) PointerToStd ¶
func (logger *Logger) PointerToStd() *stdLogger
func (*Logger) Print ¶
func (l *Logger) Print(v ...interface{})
Print sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Print.
func (*Logger) Printf ¶
Printf sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Trace ¶
Trace starts a new message with trace level.
You must call Msg on the returned event in order to send the event.
func (*Logger) UpdateContext ¶
UpdateContext updates the internal logger's context.
Use this method with caution. If unsure, prefer the With method.
func (*Logger) Warn ¶
Warn starts a new message with warn level.
You must call Msg on the returned event in order to send the event.