log

package
v0.0.0-...-ee57bd3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 7 Imported by: 7

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

Jump to

Keyboard shortcuts

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