log

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel = zapcore.DebugLevel
	// InfoLevel is the default logging priority.
	InfoLevel = zapcore.InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel = zapcore.WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel = zapcore.ErrorLevel
	// DPanicLevel logs are particularly important errors. In development the
	// logger panics after writing the message.
	DPanicLevel = zapcore.DPanicLevel
	// PanicLevel logs a message, then panics.
	PanicLevel = zapcore.PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel = zapcore.FatalLevel
)

Variables

View Source
var (
	GetLogger   = defaultLogger.Logger
	SetLevel    = defaultLogger.SetLevel
	Enabled     = defaultLogger.Enabled
	V           = defaultLogger.V
	WithContext = defaultLogger.WithContext
	WithField   = defaultLogger.WithField
	WithMap     = defaultLogger.WithMap
	WithName    = defaultLogger.WithName

	Debug   = defaultLogger.Debug
	Debugf  = defaultLogger.Debugf
	Debugw  = defaultLogger.Debugw
	Info    = defaultLogger.Info
	Infof   = defaultLogger.Infof
	Infow   = defaultLogger.Infow
	Warn    = defaultLogger.Warn
	Warnf   = defaultLogger.Warnf
	Warnw   = defaultLogger.Warnw
	Error   = defaultLogger.Error
	Errorf  = defaultLogger.Errorf
	Errorw  = defaultLogger.Errorw
	DPanic  = defaultLogger.DPanic
	DPanicf = defaultLogger.DPanicf
	DPanicw = defaultLogger.DPanicw
	Panic   = defaultLogger.Panic
	Panicf  = defaultLogger.Panicf
	Panicw  = defaultLogger.Panicw
	Fatal   = defaultLogger.Fatal
	Fatalf  = defaultLogger.Fatalf
	Fatalw  = defaultLogger.Fatalw

	Flush = defaultLogger.Flush
)
View Source
var (
	Skip        = zap.Skip
	Binary      = zap.Binary
	Bool        = zap.Bool
	Boolp       = zap.Boolp
	ByteString  = zap.ByteString
	Complex128  = zap.Complex128
	Complex128p = zap.Complex128p
	Complex64   = zap.Complex64
	Complex64p  = zap.Complex64p
	Float64     = zap.Float64
	Float64p    = zap.Float64p
	Float32     = zap.Float32
	Float32p    = zap.Float32p
	Int         = zap.Int
	Intp        = zap.Intp
	Int64       = zap.Int64
	Int64p      = zap.Int64p
	Int32       = zap.Int32
	Int32p      = zap.Int32p
	Int16       = zap.Int16
	Int16p      = zap.Int16p
	Int8        = zap.Int8
	Int8p       = zap.Int8p
	String      = zap.String
	Stringp     = zap.Stringp
	Uint        = zap.Uint
	Uintp       = zap.Uintp
	Uint64      = zap.Uint64
	Uint64p     = zap.Uint64p
	Uint32      = zap.Uint32
	Uint32p     = zap.Uint32p
	Uint16      = zap.Uint16
	Uint16p     = zap.Uint16p
	Uint8       = zap.Uint8
	Uint8p      = zap.Uint8p
	Uintptr     = zap.Uintptr
	Uintptrp    = zap.Uintptrp
	Reflect     = zap.Reflect
	Namespace   = zap.Namespace
	Stringer    = zap.Stringer
	Time        = zap.Time
	Timep       = zap.Timep
	Stack       = zap.Stack
	StackSkip   = zap.StackSkip
	Duration    = zap.Duration
	Durationp   = zap.Durationp
	Any         = zap.Any
)

Functions

func NewContext

func NewContext(ctx context.Context, l Logger) context.Context

func ResetDefault

func ResetDefault(l Logger)

Types

type Field

type Field = zapcore.Field

Field is an alias for the field structure in the underlying log frame.

type Level

type Level = zapcore.Level

Level is an alias for the level structure in the underlying log frame.

type Logger

type Logger interface {
	Enabled(lvl zapcore.Level) bool
	V(lvl int) bool
	Logger() *zap.Logger
	SetLevel(lv Level)

	Debug(v any, fields ...Field)
	Debugf(format string, v ...interface{})
	Debugw(v any, keysAndValues ...interface{})
	Info(v any, fields ...Field)
	Infof(format string, v ...interface{})
	Infow(v any, keysAndValues ...interface{})
	Warn(v any, fields ...Field)
	Warnf(format string, v ...interface{})
	Warnw(v any, keysAndValues ...interface{})
	Error(v any, fields ...Field)
	Errorf(format string, v ...interface{})
	Errorw(v any, keysAndValues ...interface{})
	DPanic(v any, fields ...Field)
	DPanicf(format string, v ...interface{})
	DPanicw(v any, keysAndValues ...interface{})
	Panic(v any, fields ...Field)
	Panicf(format string, v ...interface{})
	Panicw(v any, keysAndValues ...interface{})
	Fatal(v any, fields ...Field)
	Fatalf(format string, v ...interface{})
	Fatalw(v any, keysAndValues ...interface{})

	WithField(fields ...Field) Logger
	WithName(name string) Logger
	WithContext(ctx context.Context, keys ...string) Logger
	WithMap(fields map[string]any) Logger
	Flush() error
}

func Default

func Default() Logger

func FromContext

func FromContext(ctx context.Context) (Logger, bool)

func New

func New(writer io.Writer, level Level, opts ...Option) Logger

func NewTee

func NewTee(writers []io.Writer, level Level, opts ...Option) Logger

type Option

type Option interface {
	// contains filtered or unexported methods
}

func Development

func Development() Option

func WithCaller

func WithCaller(enabled bool) Option

func WithCallerSkip

func WithCallerSkip(skip int) Option

type Valuer

type Valuer func(ctx context.Context) Field

Valuer is returns a log value.

func App

func App(v string) Valuer

func Caller

func Caller(depth int) Valuer

Caller returns a Valuer that returns a pkg/file:line description of the caller.

func Component

func Component(v string) Valuer

func File

func File(depth int) Valuer

File returns a Valuer that returns a pkg/file:line description of the caller.

func FromAny

func FromAny(key string, vf func(context.Context) any) Valuer

func FromBinary

func FromBinary(key string, vf func(context.Context) []byte) Valuer

func FromBool

func FromBool(key string, vf func(context.Context) bool) Valuer

func FromBoolp

func FromBoolp(key string, vf func(context.Context) *bool) Valuer

func FromByteString

func FromByteString(key string, vf func(context.Context) []byte) Valuer

func FromComplex128

func FromComplex128(key string, vf func(context.Context) complex128) Valuer

func FromComplex128p

func FromComplex128p(key string, vf func(context.Context) *complex128) Valuer

func FromComplex64

func FromComplex64(key string, vf func(context.Context) complex64) Valuer

func FromComplex64p

func FromComplex64p(key string, vf func(context.Context) *complex64) Valuer

func FromDuration

func FromDuration(key string, vf func(context.Context) time.Duration) Valuer

func FromDurationp

func FromDurationp(key string, vf func(context.Context) *time.Duration) Valuer

func FromFloat32

func FromFloat32(key string, vf func(context.Context) float32) Valuer

func FromFloat32p

func FromFloat32p(key string, vf func(context.Context) *float32) Valuer

func FromFloat64

func FromFloat64(key string, vf func(context.Context) float64) Valuer

func FromFloat64p

func FromFloat64p(key string, vf func(context.Context) *float64) Valuer

func FromInt

func FromInt(key string, vf func(context.Context) int) Valuer

func FromInt16

func FromInt16(key string, vf func(context.Context) int16) Valuer

func FromInt16p

func FromInt16p(key string, vf func(context.Context) *int16) Valuer

func FromInt32

func FromInt32(key string, vf func(context.Context) int32) Valuer

func FromInt32p

func FromInt32p(key string, vf func(context.Context) *int32) Valuer

func FromInt64

func FromInt64(key string, vf func(context.Context) int64) Valuer

func FromInt64p

func FromInt64p(key string, vf func(context.Context) *int64) Valuer

func FromInt8

func FromInt8(key string, vf func(context.Context) int8) Valuer

func FromInt8p

func FromInt8p(key string, vf func(context.Context) *int8) Valuer

func FromIntp

func FromIntp(key string, vf func(context.Context) *int) Valuer

func FromNamespace

func FromNamespace(key string) Valuer

func FromReflect

func FromReflect(key string, vf func(context.Context) any) Valuer

func FromStack

func FromStack(key string) Valuer

func FromStackSkip

func FromStackSkip(key string, skip int) Valuer

func FromString

func FromString(key string, vf func(context.Context) string) Valuer

func FromStringer

func FromStringer(key string, vf func(context.Context) fmt.Stringer) Valuer

func FromStringp

func FromStringp(key string, vf func(context.Context) *string) Valuer

func FromTime

func FromTime(key string, vf func(context.Context) time.Time) Valuer

func FromTimep

func FromTimep(key string, vf func(context.Context) *time.Time) Valuer

func FromUint

func FromUint(key string, vf func(context.Context) uint) Valuer

func FromUint16

func FromUint16(key string, vf func(context.Context) uint16) Valuer

func FromUint16p

func FromUint16p(key string, vf func(context.Context) *uint16) Valuer

func FromUint32

func FromUint32(key string, vf func(context.Context) uint32) Valuer

func FromUint32p

func FromUint32p(key string, vf func(context.Context) *uint32) Valuer

func FromUint64

func FromUint64(key string, vf func(context.Context) uint64) Valuer

func FromUint64p

func FromUint64p(key string, vf func(context.Context) *uint64) Valuer

func FromUint8

func FromUint8(key string, vf func(context.Context) uint8) Valuer

func FromUint8p

func FromUint8p(key string, vf func(context.Context) *uint8) Valuer

func FromUintp

func FromUintp(key string, vf func(context.Context) *uint) Valuer

func FromUintptr

func FromUintptr(key string, vf func(context.Context) uintptr) Valuer

func FromUintptrp

func FromUintptrp(key string, vf func(context.Context) *uintptr) Valuer

func ImmutAny

func ImmutAny(key string, v any) Valuer

func ImmutBinary

func ImmutBinary(key string, v []byte) Valuer

func ImmutBool

func ImmutBool(key string, v bool) Valuer

func ImmutBoolp

func ImmutBoolp(key string, v *bool) Valuer

func ImmutByteString

func ImmutByteString(key string, v []byte) Valuer

func ImmutComplex128

func ImmutComplex128(key string, v complex128) Valuer

func ImmutComplex128p

func ImmutComplex128p(key string, v *complex128) Valuer

func ImmutComplex64

func ImmutComplex64(key string, v complex64) Valuer

func ImmutComplex64p

func ImmutComplex64p(key string, v *complex64) Valuer

func ImmutDuration

func ImmutDuration(key string, v time.Duration) Valuer

func ImmutDurationp

func ImmutDurationp(key string, v *time.Duration) Valuer

func ImmutFloat32

func ImmutFloat32(key string, v float32) Valuer

func ImmutFloat32p

func ImmutFloat32p(key string, v *float32) Valuer

func ImmutFloat64

func ImmutFloat64(key string, v float64) Valuer

func ImmutFloat64p

func ImmutFloat64p(key string, v *float64) Valuer

func ImmutInt

func ImmutInt(key string, v int) Valuer

func ImmutInt16

func ImmutInt16(key string, v int16) Valuer

func ImmutInt16p

func ImmutInt16p(key string, v *int16) Valuer

func ImmutInt32

func ImmutInt32(key string, v int32) Valuer

func ImmutInt32p

func ImmutInt32p(key string, v *int32) Valuer

func ImmutInt64

func ImmutInt64(key string, v int64) Valuer

func ImmutInt64p

func ImmutInt64p(key string, v *int64) Valuer

func ImmutInt8

func ImmutInt8(key string, v int8) Valuer

func ImmutInt8p

func ImmutInt8p(key string, v *int8) Valuer

func ImmutIntp

func ImmutIntp(key string, v *int) Valuer

func ImmutReflect

func ImmutReflect(key string, v any) Valuer

func ImmutString

func ImmutString(key string, v string) Valuer

func ImmutStringer

func ImmutStringer(key string, v fmt.Stringer) Valuer

func ImmutStringp

func ImmutStringp(key string, v *string) Valuer

func ImmutTime

func ImmutTime(key string, v time.Time) Valuer

func ImmutTimep

func ImmutTimep(key string, v *time.Time) Valuer

func ImmutUint

func ImmutUint(key string, v uint) Valuer

func ImmutUint16

func ImmutUint16(key string, v uint16) Valuer

func ImmutUint16p

func ImmutUint16p(key string, v *uint16) Valuer

func ImmutUint32

func ImmutUint32(key string, v uint32) Valuer

func ImmutUint32p

func ImmutUint32p(key string, v *uint32) Valuer

func ImmutUint64

func ImmutUint64(key string, v uint64) Valuer

func ImmutUint64p

func ImmutUint64p(key string, v *uint64) Valuer

func ImmutUint8

func ImmutUint8(key string, v uint8) Valuer

func ImmutUint8p

func ImmutUint8p(key string, v *uint8) Valuer

func ImmutUintp

func ImmutUintp(key string, v *uint) Valuer

func ImmutUintptr

func ImmutUintptr(key string, v uintptr) Valuer

func ImmutUintptrp

func ImmutUintptrp(key string, v *uintptr) Valuer

func Kind

func Kind(v string) Valuer

func Module

func Module(v string) Valuer

func Package

func Package(v string) Valuer

Package returns a Valuer that returns a immutable Valuer which key is pkg

func RequestId

func RequestId(f func(c context.Context) string) Valuer

func TraceId

func TraceId(f func(c context.Context) string) Valuer

func Type

func Type(v string) Valuer

func Unit

func Unit(v string) Valuer

Jump to

Keyboard shortcuts

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