zapadapter

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package zapadapter provides a zap and zap-sugared adapter for onelog. See _examples/ for usage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdapter

func NewAdapter(l *zap.Logger) onelog.Logger

NewAdapter creates a new zap adapter for onelog.

func NewSugarAdapter

func NewSugarAdapter(l *zap.SugaredLogger) onelog.Logger

NewSugarAdapter creates a new zap-sugared adapter for onelog.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter is a zap adapter for onelog. It implements the onelog.Logger interface.

func (*Adapter) Debug

func (a *Adapter) Debug() onelog.LoggerContext

Debug returns a LoggerContext for a debug log. To send the log, use the Msg or Msgf methods.

func (*Adapter) Error

func (a *Adapter) Error() onelog.LoggerContext

Error returns a LoggerContext for a error log. To send the log, use the Msg or Msgf methods.

func (*Adapter) Fatal

func (a *Adapter) Fatal() onelog.LoggerContext

Fatal returns a LoggerContext for a fatal log. To send the log, use the Msg or Msgf methods.

func (*Adapter) Info

func (a *Adapter) Info() onelog.LoggerContext

Info returns a LoggerContext for a info log. To send the log, use the Msg or Msgf methods.

func (*Adapter) Warn

func (a *Adapter) Warn() onelog.LoggerContext

Warn returns a LoggerContext for a warn log. To send the log, use the Msg or Msgf methods.

func (*Adapter) With added in v0.6.0

func (a *Adapter) With(fields ...any) onelog.Logger

With returns the logger with the given fields.

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context is the zap logging context. It implements the onelog.LoggerContext interface.

func (*Context) AnErr

func (c *Context) AnErr(key string, err error) onelog.LoggerContext

AnErr adds the field key with val as a error to the logger context.

func (*Context) Any

func (c *Context) Any(key string, value any) onelog.LoggerContext

Any adds the field key with val as a arbitrary value to the logger context.

func (*Context) Bool

func (c *Context) Bool(key string, value bool) onelog.LoggerContext

Bool adds the field key with val as a bool to the logger context.

func (*Context) Bools

func (c *Context) Bools(key string, value []bool) onelog.LoggerContext

Bools adds the field key with val as a []bool to the logger context.

func (*Context) Bytes added in v0.5.0

func (c *Context) Bytes(key string, value []byte) onelog.LoggerContext

Bytes adds the field key with val as a []byte to the logger context.

func (*Context) Dur

func (c *Context) Dur(key string, value time.Duration) onelog.LoggerContext

Dur adds the field key with val as a time.Duration to the logger context.

func (*Context) Durs

func (c *Context) Durs(key string, value []time.Duration) onelog.LoggerContext

Durs adds the field key with val as a []time.Duration to the logger context.

func (*Context) Err

func (c *Context) Err(err error) onelog.LoggerContext

Err adds the field key with val as a error to the logger context.

func (*Context) Errs

func (c *Context) Errs(key string, errs []error) onelog.LoggerContext

Errs adds the field key with val as a []error to the logger context.

func (*Context) Fields

func (c *Context) Fields(fields onelog.Fields) onelog.LoggerContext

func (*Context) Float32

func (c *Context) Float32(key string, value float32) onelog.LoggerContext

Float32 adds the field key with val as a float32 to the logger context.

func (*Context) Float64

func (c *Context) Float64(key string, value float64) onelog.LoggerContext

Float64 adds the field key with val as a float64 to the logger context.

func (*Context) Floats32

func (c *Context) Floats32(key string, value []float32) onelog.LoggerContext

Floats32 adds the field key with val as a []float32 to the logger context.

func (*Context) Floats64

func (c *Context) Floats64(key string, value []float64) onelog.LoggerContext

Floats64 adds the field key with val as a []float64 to the logger context.

func (*Context) Hex added in v0.5.0

func (c *Context) Hex(key string, value []byte) onelog.LoggerContext

Hex adds the field key with val as a hex string to the logger context.

func (*Context) IPAddr

func (c *Context) IPAddr(key string, value net.IP) onelog.LoggerContext

IPAddr adds the field key with val as a net.IP to the logger context.

func (*Context) IPPrefix

func (c *Context) IPPrefix(key string, value net.IPNet) onelog.LoggerContext

IPPrefix adds the field key with val as a net.IPNet to the logger context.

func (*Context) Int

func (c *Context) Int(key string, value int) onelog.LoggerContext

Int adds the field key with val as a int to the logger context.

func (*Context) Int16

func (c *Context) Int16(key string, value int16) onelog.LoggerContext

Int16 adds the field key with val as a int16 to the logger context.

func (*Context) Int32

func (c *Context) Int32(key string, value int32) onelog.LoggerContext

Int32 adds the field key with val as a int32 to the logger context.

func (*Context) Int64

func (c *Context) Int64(key string, value int64) onelog.LoggerContext

Int64 adds the field key with val as a int64 to the logger context.

func (*Context) Int8

func (c *Context) Int8(key string, value int8) onelog.LoggerContext

Int8 adds the field key with val as a int8 to the logger context.

func (*Context) Ints

func (c *Context) Ints(key string, value []int) onelog.LoggerContext

Ints adds the field key with val as a []int to the logger context.

func (*Context) Ints16

func (c *Context) Ints16(key string, value []int16) onelog.LoggerContext

Ints16 adds the field key with val as a []int16 to the logger context.

func (*Context) Ints32

func (c *Context) Ints32(key string, value []int32) onelog.LoggerContext

Ints32 adds the field key with val as a []int32 to the logger context.

func (*Context) Ints64

func (c *Context) Ints64(key string, value []int64) onelog.LoggerContext

Ints64 adds the field key with val as a []int64 to the logger context.

func (*Context) Ints8

func (c *Context) Ints8(key string, value []int8) onelog.LoggerContext

Ints8 adds the field key with val as a []int8 to the logger context.

func (*Context) MACAddr

func (c *Context) MACAddr(key string, value net.HardwareAddr) onelog.LoggerContext

MACAddr adds the field key with val as a net.HardwareAddr to the logger context.

func (*Context) Msg

func (c *Context) Msg(msg string)

Msg sends the LoggerContext with msg to the logger.

func (*Context) Msgf

func (c *Context) Msgf(format string, v ...any)

Msgf sends the LoggerContext with formatted msg to the logger.

func (*Context) RawJSON added in v0.5.0

func (c *Context) RawJSON(key string, value []byte) onelog.LoggerContext

RawJSON adds the field key with val as a raw json string to the logger context.

func (*Context) Str

func (c *Context) Str(key string, value string) onelog.LoggerContext

Str adds the field key with val as a string to the logger context.

func (*Context) Stringer added in v0.4.0

func (c *Context) Stringer(key string, val fmt.Stringer) onelog.LoggerContext

Stringer adds the field key with val as a fmt.Stringer to the logger context.

func (*Context) Stringers added in v0.4.0

func (c *Context) Stringers(key string, vals []fmt.Stringer) onelog.LoggerContext

Stringers adds the field key with val as a []fmt.Stringer to the logger context.

func (*Context) Strs

func (c *Context) Strs(key string, value []string) onelog.LoggerContext

Strs adds the field key with val as a []string to the logger context.

func (*Context) Time

func (c *Context) Time(key string, value time.Time) onelog.LoggerContext

Time adds the field key with val as a time.Time to the logger context.

func (*Context) TimeDiff added in v0.3.0

func (c *Context) TimeDiff(key string, begin, end time.Time) onelog.LoggerContext

TimeDiff adds the field key with begin and end as a time.Time to the logger context.

func (*Context) Times

func (c *Context) Times(key string, value []time.Time) onelog.LoggerContext

Times adds the field key with val as a []time.Time to the logger context.

func (*Context) Uint

func (c *Context) Uint(key string, value uint) onelog.LoggerContext

Uint adds the field key with val as a uint to the logger context.

func (*Context) Uint16

func (c *Context) Uint16(key string, value uint16) onelog.LoggerContext

Uint16 adds the field key with val as a uint16 to the logger context.

func (*Context) Uint32

func (c *Context) Uint32(key string, value uint32) onelog.LoggerContext

Uint32 adds the field key with val as a uint32 to the logger context.

func (*Context) Uint64

func (c *Context) Uint64(key string, value uint64) onelog.LoggerContext

Uint64 adds the field key with val as a uint64 to the logger context.

func (*Context) Uint8

func (c *Context) Uint8(key string, value uint8) onelog.LoggerContext

Uint8 adds the field key with val as a uint8 to the logger context.

func (*Context) Uints

func (c *Context) Uints(key string, value []uint) onelog.LoggerContext

Uints adds the field key with val as a []uint to the logger context.

func (*Context) Uints16

func (c *Context) Uints16(key string, value []uint16) onelog.LoggerContext

Uints16 adds the field key with val as a []uint16 to the logger context.

func (*Context) Uints32

func (c *Context) Uints32(key string, value []uint32) onelog.LoggerContext

Uints32 adds the field key with val as a []uint32 to the logger context.

func (*Context) Uints64

func (c *Context) Uints64(key string, value []uint64) onelog.LoggerContext

Uints64 adds the field key with val as a []uint64 to the logger context.

func (*Context) Uints8

func (c *Context) Uints8(key string, value []uint8) onelog.LoggerContext

Uints8 adds the field key with val as a []uint8 to the logger context.

type SugarAdapter

type SugarAdapter struct {
	// contains filtered or unexported fields
}

SugarAdapter is a zap-sugared adapter for onelog. It implements the onelog.Logger interface.

func (*SugarAdapter) Debug

func (a *SugarAdapter) Debug() onelog.LoggerContext

Debug returns a LoggerContext for a debug log. To send the log, use the Msg or Msgf methods.

func (*SugarAdapter) Error

func (a *SugarAdapter) Error() onelog.LoggerContext

Error returns a LoggerContext for an error log. To send the log, use the Msg or Msgf methods.

func (*SugarAdapter) Fatal

func (a *SugarAdapter) Fatal() onelog.LoggerContext

Fatal returns a LoggerContext for a fatal log. To send the log, use the Msg or Msgf methods.

func (*SugarAdapter) Info

func (a *SugarAdapter) Info() onelog.LoggerContext

Info returns a LoggerContext for an info log. To send the log, use the Msg or Msgf methods.

func (*SugarAdapter) Warn

func (a *SugarAdapter) Warn() onelog.LoggerContext

Warn returns a LoggerContext for a warning log. To send the log, use the Msg or Msgf methods.

func (*SugarAdapter) With added in v0.6.0

func (a *SugarAdapter) With(fields ...any) onelog.Logger

With returns the logger with the given fields.

type SugarContext

type SugarContext struct {
	// contains filtered or unexported fields
}

SugarContext is the zap-sugared logging context. It implements the onelog.LoggerContext interface.

func (*SugarContext) AnErr

func (c *SugarContext) AnErr(key string, err error) onelog.LoggerContext

AnErr adds the field "error" with err as a string to the logger context.

func (*SugarContext) Any

func (c *SugarContext) Any(key string, value any) onelog.LoggerContext

Any adds the field key with val as a any to the logger context.

func (*SugarContext) Bool

func (c *SugarContext) Bool(key string, value bool) onelog.LoggerContext

Bool adds the field key with val as a bool to the logger context.

func (*SugarContext) Bools

func (c *SugarContext) Bools(key string, value []bool) onelog.LoggerContext

Bools adds the field key with val as a []bool to the logger context.

func (*SugarContext) Bytes added in v0.5.0

func (c *SugarContext) Bytes(key string, value []byte) onelog.LoggerContext

Bytes adds the field key with val as a []byte to the logger context.

func (*SugarContext) Dur

func (c *SugarContext) Dur(key string, value time.Duration) onelog.LoggerContext

Dur adds the field key with val as a time.Duration to the logger context.

func (*SugarContext) Durs

func (c *SugarContext) Durs(key string, value []time.Duration) onelog.LoggerContext

Durs adds the field key with val as a []time.Duration to the logger context.

func (*SugarContext) Err

func (c *SugarContext) Err(err error) onelog.LoggerContext

Err adds the field "error" with err as a string to the logger context.

func (*SugarContext) Errs

func (c *SugarContext) Errs(key string, errs []error) onelog.LoggerContext

Errs adds the field key with val as a []error to the logger context.

func (*SugarContext) Fields

func (c *SugarContext) Fields(fields onelog.Fields) onelog.LoggerContext

Fields adds the field key with val as a Fields to the logger context.

func (*SugarContext) Float32

func (c *SugarContext) Float32(key string, value float32) onelog.LoggerContext

Float32 adds the field key with val as a float32 to the logger context.

func (*SugarContext) Float64

func (c *SugarContext) Float64(key string, value float64) onelog.LoggerContext

Float64 adds the field key with val as a float64 to the logger context.

func (*SugarContext) Floats32

func (c *SugarContext) Floats32(key string, value []float32) onelog.LoggerContext

Floats32 adds the field key with val as a []float32 to the logger context.

func (*SugarContext) Floats64

func (c *SugarContext) Floats64(key string, value []float64) onelog.LoggerContext

Floats64 adds the field key with val as a []float64 to the logger context.

func (*SugarContext) Hex added in v0.5.0

func (c *SugarContext) Hex(key string, value []byte) onelog.LoggerContext

Hex adds the field key with val as a hex string to the logger context.

func (*SugarContext) IPAddr

func (c *SugarContext) IPAddr(key string, value net.IP) onelog.LoggerContext

IPAddr adds the field key with val as a net.IP to the logger context.

func (*SugarContext) IPPrefix

func (c *SugarContext) IPPrefix(key string, value net.IPNet) onelog.LoggerContext

IPPrefix adds the field key with val as a net.IPNet to the logger context.

func (*SugarContext) Int

func (c *SugarContext) Int(key string, value int) onelog.LoggerContext

Int adds the field key with val as a int to the logger context.

func (*SugarContext) Int16

func (c *SugarContext) Int16(key string, value int16) onelog.LoggerContext

Int16 adds the field key with val as a int16 to the logger context.

func (*SugarContext) Int32

func (c *SugarContext) Int32(key string, value int32) onelog.LoggerContext

Int32 adds the field key with val as a int32 to the logger context.

func (*SugarContext) Int64

func (c *SugarContext) Int64(key string, value int64) onelog.LoggerContext

Int64 adds the field key with val as a int64 to the logger context.

func (*SugarContext) Int8

func (c *SugarContext) Int8(key string, value int8) onelog.LoggerContext

Int8 adds the field key with val as a int8 to the logger context.

func (*SugarContext) Ints

func (c *SugarContext) Ints(key string, value []int) onelog.LoggerContext

Ints adds the field key with val as a []int to the logger context.

func (*SugarContext) Ints16

func (c *SugarContext) Ints16(key string, value []int16) onelog.LoggerContext

Ints16 adds the field key with val as a []int16 to the logger context.

func (*SugarContext) Ints32

func (c *SugarContext) Ints32(key string, value []int32) onelog.LoggerContext

Ints32 adds the field key with val as a []int32 to the logger context.

func (*SugarContext) Ints64

func (c *SugarContext) Ints64(key string, value []int64) onelog.LoggerContext

Ints64 adds the field key with val as a []int64 to the logger context.

func (*SugarContext) Ints8

func (c *SugarContext) Ints8(key string, value []int8) onelog.LoggerContext

Ints8 adds the field key with val as a []int8 to the logger context.

func (*SugarContext) MACAddr

func (c *SugarContext) MACAddr(key string, value net.HardwareAddr) onelog.LoggerContext

MACAddr adds the field key with val as a net.HardwareAddr to the logger context.

func (*SugarContext) Msg

func (c *SugarContext) Msg(msg string)

Msg sends the LoggerContext with msg to the logger.

func (*SugarContext) Msgf

func (c *SugarContext) Msgf(format string, v ...any)

Msgf sends the LoggerContext with formatted msg to the logger.

func (*SugarContext) RawJSON added in v0.5.0

func (c *SugarContext) RawJSON(key string, value []byte) onelog.LoggerContext

RawJSON adds the field key with val as a json.RawMessage to the logger context.

func (*SugarContext) Str

func (c *SugarContext) Str(key string, value string) onelog.LoggerContext

Str adds the field key with val as a string to the logger context.

func (*SugarContext) Stringer added in v0.4.0

func (c *SugarContext) Stringer(key string, val fmt.Stringer) onelog.LoggerContext

Stringer adds the field key with val as a fmt.Stringer to the logger context.

func (*SugarContext) Stringers added in v0.4.0

func (c *SugarContext) Stringers(key string, vals []fmt.Stringer) onelog.LoggerContext

Stringers adds the field key with val as a []fmt.Stringer to the logger context.

func (*SugarContext) Strs

func (c *SugarContext) Strs(key string, value []string) onelog.LoggerContext

Strs adds the field key with val as a []string to the logger context.

func (*SugarContext) Time

func (c *SugarContext) Time(key string, value time.Time) onelog.LoggerContext

Time adds the field key with val as a time.Time to the logger context.

func (*SugarContext) TimeDiff added in v0.3.0

func (c *SugarContext) TimeDiff(key string, begin, end time.Time) onelog.LoggerContext

TimeDiff adds the field key with begin and end as a time.Time to the logger context.

func (*SugarContext) Times

func (c *SugarContext) Times(key string, value []time.Time) onelog.LoggerContext

Times adds the field key with val as a []time.Time to the logger context.

func (*SugarContext) Uint

func (c *SugarContext) Uint(key string, value uint) onelog.LoggerContext

Uint adds the field key with val as a uint to the logger context.

func (*SugarContext) Uint16

func (c *SugarContext) Uint16(key string, value uint16) onelog.LoggerContext

Uint16 adds the field key with val as a uint16 to the logger context.

func (*SugarContext) Uint32

func (c *SugarContext) Uint32(key string, value uint32) onelog.LoggerContext

Uint32 adds the field key with val as a uint32 to the logger context.

func (*SugarContext) Uint64

func (c *SugarContext) Uint64(key string, value uint64) onelog.LoggerContext

Uint64 adds the field key with val as a uint64 to the logger context.

func (*SugarContext) Uint8

func (c *SugarContext) Uint8(key string, value uint8) onelog.LoggerContext

Uint8 adds the field key with val as a uint8 to the logger context.

func (*SugarContext) Uints

func (c *SugarContext) Uints(key string, value []uint) onelog.LoggerContext

Uints adds the field key with val as a []uint to the logger context.

func (*SugarContext) Uints16

func (c *SugarContext) Uints16(key string, value []uint16) onelog.LoggerContext

Uints16 adds the field key with val as a []uint16 to the logger context.

func (*SugarContext) Uints32

func (c *SugarContext) Uints32(key string, value []uint32) onelog.LoggerContext

Uints32 adds the field key with val as a []uint32 to the logger context.

func (*SugarContext) Uints64

func (c *SugarContext) Uints64(key string, value []uint64) onelog.LoggerContext

Uints64 adds the field key with val as a []uint64 to the logger context.

func (*SugarContext) Uints8

func (c *SugarContext) Uints8(key string, value []uint8) onelog.LoggerContext

Uints8 adds the field key with val as a []uint8 to the logger context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL