Documentation
¶
Index ¶
- func SetLoggerLevel(level zerolog.Level)
- func SetLoggerOutput(w io.Writer)
- func UseColorLogger()
- func UseConsoleLogger()
- type ColorWriter
- type Wrap
- func (l *Wrap) AnErr(key string, err error) *Wrap
- func (l *Wrap) Array(key string, arr zerolog.LogArrayMarshaler) *Wrap
- func (l *Wrap) Bool(key string, b bool) *Wrap
- func (l *Wrap) Bools(key string, b []bool) *Wrap
- func (l *Wrap) Bytes(key string, val []byte) *Wrap
- func (l *Wrap) Dur(key string, d time.Duration) *Wrap
- func (l *Wrap) Durs(key string, d []time.Duration) *Wrap
- func (l *Wrap) Err(err error) *Wrap
- func (l *Wrap) Errs(key string, errs []error) *Wrap
- func (l *Wrap) Fields(fields map[string]interface{}) *Wrap
- func (l *Wrap) Float32(key string, f float32) *Wrap
- func (l *Wrap) Float64(key string, f float64) *Wrap
- func (l *Wrap) Floats32(key string, f []float32) *Wrap
- func (l *Wrap) Floats64(key string, f []float64) *Wrap
- func (l *Wrap) Int(key string, i int) *Wrap
- func (l *Wrap) Int16(key string, i int16) *Wrap
- func (l *Wrap) Int32(key string, i int32) *Wrap
- func (l *Wrap) Int64(key string, i int64) *Wrap
- func (l *Wrap) Int8(key string, i int8) *Wrap
- func (l *Wrap) Interface(key string, i interface{}) *Wrap
- func (l *Wrap) Ints(key string, i []int) *Wrap
- func (l *Wrap) Ints16(key string, i []int16) *Wrap
- func (l *Wrap) Ints32(key string, i []int32) *Wrap
- func (l *Wrap) Ints64(key string, i []int64) *Wrap
- func (l *Wrap) Ints8(key string, i []int8) *Wrap
- func (l Wrap) Msg(msg string)
- func (l Wrap) Msgf(format string, v ...interface{})
- func (l *Wrap) Object(key string, obj zerolog.LogObjectMarshaler) *Wrap
- func (l *Wrap) Str(key, val string) *Wrap
- func (l *Wrap) Strs(key string, vals []string) *Wrap
- func (l *Wrap) Time(key string, t time.Time) *Wrap
- func (l *Wrap) TimeDiff(key string, t time.Time, start time.Time) *Wrap
- func (l *Wrap) Times(key string, t []time.Time) *Wrap
- func (l *Wrap) Timestamp() *Wrap
- func (l *Wrap) Uint(key string, i uint) *Wrap
- func (l *Wrap) Uint16(key string, i uint16) *Wrap
- func (l *Wrap) Uint32(key string, i uint32) *Wrap
- func (l *Wrap) Uint64(key string, i uint64) *Wrap
- func (l *Wrap) Uint8(key string, i uint8) *Wrap
- func (l *Wrap) Uints(key string, i []uint) *Wrap
- func (l *Wrap) Uints16(key string, i []uint16) *Wrap
- func (l *Wrap) Uints32(key string, i []uint32) *Wrap
- func (l *Wrap) Uints64(key string, i []uint64) *Wrap
- func (l *Wrap) Uints8(key string, i []uint8) *Wrap
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetLoggerLevel ¶
SetLoggerLevel sets the log level of logger.
func UseColorLogger ¶
func UseColorLogger()
UseColorLogger will writes the logs to stderr with colorful pretty format.
func UseConsoleLogger ¶
func UseConsoleLogger()
UseConsoleLogger will writes the logs to stderr with pretty format without color.
Example ¶
package main import ( "github.com/rs/zerolog" "github.com/tuotoo/biu/log" ) func main() { log.UseConsoleLogger() log.Debug().Msg("hello") log.SetLoggerLevel(zerolog.InfoLevel) log.Debug().Msg("hello") log.Info().Int("int", 1).Msg("hello") }
Output:
Types ¶
type ColorWriter ¶
type ColorWriter struct {
WithColor bool
}
ColorWriter is a writer for writing pretty log to console
type Wrap ¶ added in v0.4.3
func (*Wrap) AnErr ¶ added in v0.4.3
AnErr adds the field key with err as a string to the *Event context. If err is nil, no field is added.
func (*Wrap) Array ¶ added in v0.4.3
func (l *Wrap) Array(key string, arr zerolog.LogArrayMarshaler) *Wrap
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 (*Wrap) Bool ¶ added in v0.4.3
Bool adds the field key with val as a bool to the *Event context.
func (*Wrap) Bools ¶ added in v0.4.3
Bools adds the field key with val as a []bool to the *Event context.
func (*Wrap) Bytes ¶ added in v0.4.3
Bytes adds the field key with val as a string to the *Event context.
Runes outside of normal ASCII ranges will be hex-encoded in the resulting JSON.
func (*Wrap) Dur ¶ added in v0.4.3
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 (*Wrap) Durs ¶ added in v0.4.3
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 (*Wrap) Err ¶ added in v0.4.3
Err adds the field "error" with err as a string to the *Event context. If err is nil, no field is added. To customize the key name, change zerolog.ErrorFieldName.
func (*Wrap) Errs ¶ added in v0.4.3
Errs adds the field key with errs as an array of strings to the *Event context. If err is nil, no field is added.
func (*Wrap) Fields ¶ added in v0.4.3
Fields is a helper function to use a map to set fields using type assertion.
func (*Wrap) Float32 ¶ added in v0.4.3
Float32 adds the field key with f as a float32 to the *Event context.
func (*Wrap) Float64 ¶ added in v0.4.3
Float64 adds the field key with f as a float64 to the *Event context.
func (*Wrap) Floats32 ¶ added in v0.4.3
Floats32 adds the field key with f as a []float32 to the *Event context.
func (*Wrap) Floats64 ¶ added in v0.4.3
Floats64 adds the field key with f as a []float64 to the *Event context.
func (*Wrap) Int16 ¶ added in v0.4.3
Int16 adds the field key with i as a int16 to the *Event context.
func (*Wrap) Int32 ¶ added in v0.4.3
Int32 adds the field key with i as a int32 to the *Event context.
func (*Wrap) Int64 ¶ added in v0.4.3
Int64 adds the field key with i as a int64 to the *Event context.
func (*Wrap) Interface ¶ added in v0.4.3
Interface adds the field key with i marshaled using reflection.
func (*Wrap) Ints ¶ added in v0.4.3
Ints adds the field key with i as a []int to the *Event context.
func (*Wrap) Ints16 ¶ added in v0.4.3
Ints16 adds the field key with i as a []int16 to the *Event context.
func (*Wrap) Ints32 ¶ added in v0.4.3
Ints32 adds the field key with i as a []int32 to the *Event context.
func (*Wrap) Ints64 ¶ added in v0.4.3
Ints64 adds the field key with i as a []int64 to the *Event context.
func (*Wrap) Ints8 ¶ added in v0.4.3
Ints8 adds the field key with i as a []int8 to the *Event context.
func (Wrap) Msg ¶ added in v0.4.3
Msg sends the *Wrap with msg added as the message field if not empty.
NOTICE: once this method is called, the *Wrap should be disposed. Calling Msg twice can have unexpected result.
func (*Wrap) Object ¶ added in v0.4.3
func (l *Wrap) Object(key string, obj zerolog.LogObjectMarshaler) *Wrap
Object marshals an object that implement the LogObjectMarshaler interface.
func (*Wrap) Str ¶ added in v0.4.3
Str adds the field key with val as a string to the *Event context.
func (*Wrap) Strs ¶ added in v0.4.3
Strs adds the field key with vals as a []string to the *Event context.
func (*Wrap) Time ¶ added in v0.4.3
Time adds the field key with t formated as string using zerolog.TimeFieldFormat.
func (*Wrap) TimeDiff ¶ added in v0.4.3
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 (*Wrap) Times ¶ added in v0.4.3
Times adds the field key with t formated as string using zerolog.TimeFieldFormat.
func (*Wrap) Timestamp ¶ added in v0.4.3
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.
func (*Wrap) Uint16 ¶ added in v0.4.3
Uint16 adds the field key with i as a uint16 to the *Event context.
func (*Wrap) Uint32 ¶ added in v0.4.3
Uint32 adds the field key with i as a uint32 to the *Event context.
func (*Wrap) Uint64 ¶ added in v0.4.3
Uint64 adds the field key with i as a uint64 to the *Event context.
func (*Wrap) Uint8 ¶ added in v0.4.3
Uint8 adds the field key with i as a uint8 to the *Event context.
func (*Wrap) Uints ¶ added in v0.4.3
Uints adds the field key with i as a []int to the *Event context.
func (*Wrap) Uints16 ¶ added in v0.4.3
Uints16 adds the field key with i as a []int16 to the *Event context.
func (*Wrap) Uints32 ¶ added in v0.4.3
Uints32 adds the field key with i as a []int32 to the *Event context.