log

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugLevel = zapcore.DebugLevel
	InfoLevel  = zapcore.InfoLevel
	WarnLevel  = zapcore.WarnLevel
	ErrorLevel = zapcore.ErrorLevel
	PanicLevel = zapcore.PanicLevel
	FatalLevel = zapcore.FatalLevel
)

Variables

View Source
var (
	WrapCore      = zap.WrapCore
	Hooks         = zap.Hooks
	Fields        = zap.Fields
	ErrorOutput   = zap.ErrorOutput
	Development   = zap.Development
	AddCaller     = zap.AddCaller
	WithCaller    = zap.WithCaller
	AddCallerSkip = zap.AddCallerSkip
	AddStacktrace = zap.AddStacktrace
	IncreaseLevel = zap.IncreaseLevel
	WithFatalHook = zap.WithFatalHook
	WithClock     = zap.WithClock
)
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
	Object      = zap.Object
	Inline      = zap.Inline
	Any         = zap.Any
)

Functions

func Debug

func Debug(msg string, fields ...Field)

func Debugf

func Debugf(template string, args ...interface{})

func Error

func Error(msg string, fields ...Field)

func Errorf

func Errorf(template string, args ...interface{})

func Fatal

func Fatal(msg string, fields ...Field)

func Fatalf

func Fatalf(template string, args ...interface{})

func Info

func Info(msg string, fields ...Field)

func Infof

func Infof(template string, args ...interface{})

func InitLog

func InitLog()

InitLog log instance init

func NewProductionRotateBySize

func NewProductionRotateBySize(filename string) io.Writer

NewProductionRotateBySize Create an io.Writer that rotates by size

func NewProductionRotateByTime

func NewProductionRotateByTime(filename string) io.Writer

NewProductionRotateByTime Create an io.Writer that rotates by time

func NewRotateBySize

func NewRotateBySize(cfg *RotateConfig) io.Writer

func NewRotateByTime

func NewRotateByTime(cfg *RotateConfig) io.Writer

func Panic

func Panic(msg string, fields ...Field)

func Panicf

func Panicf(template string, args ...interface{})

func ReplaceDefault

func ReplaceDefault(l *Logger)

func SetLevel

func SetLevel(level Level)

func Sync

func Sync() error

func Warn

func Warn(msg string, fields ...Field)

func Warnf

func Warnf(template string, args ...interface{})

Types

type Field

type Field = zap.Field

type Level

type Level = zapcore.Level

type LevelEnablerFunc

type LevelEnablerFunc func(Level) bool

type Logger

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

func Default

func Default() *Logger

func New

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

func NewTee

func NewTee(tees []TeeOption, opts ...Option) *Logger

NewTee writes multiple outputs based on log level https://pkg.go.dev/go.uber.org/zap#example-package-AdvancedConfiguration

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...Field)

func (*Logger) Debugf

func (l *Logger) Debugf(template string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...Field)

func (*Logger) Errorf

func (l *Logger) Errorf(template string, args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...Field)

func (*Logger) Fatalf

func (l *Logger) Fatalf(template string, args ...interface{})

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...Field)

func (*Logger) Infof

func (l *Logger) Infof(template string, args ...interface{})

func (*Logger) Panic

func (l *Logger) Panic(msg string, fields ...Field)

func (*Logger) Panicf

func (l *Logger) Panicf(template string, args ...interface{})

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel dynamically changes the log level Invalid for Loggers created using NewTee, because NewTee is intended to be based on different log levels For multiple zap.Core created, the log levels of multiple zap.Core should not be unified through SetLevel.

func (*Logger) Sync

func (l *Logger) Sync() error

func (*Logger) SyncSugar

func (l *Logger) SyncSugar() error

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...Field)

func (*Logger) Warnf

func (l *Logger) Warnf(template string, args ...interface{})

type Option

type Option = zap.Option

type RotateConfig

type RotateConfig struct {
	// shared configuration
	Filename string // Full file name
	MaxAge   int    // Maximum number of days to keep old log files

	// Configuration by time rotation
	RotationTime time.Duration // Log file rotation time

	// Rotate configuration by size
	MaxSize    int  // Maximum log file size (MB)
	MaxBackups int  // Maximum number of log files to keep
	Compress   bool // Whether to compress and archive log files
	LocalTime  bool // Whether to use local time, default UTC time
}

func NewProductionRotateConfig

func NewProductionRotateConfig(filename string) *RotateConfig

type TeeOption

type TeeOption struct {
	Out io.Writer
	LevelEnablerFunc
}

Jump to

Keyboard shortcuts

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