log

package
v0.0.0-...-bd7812a Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConsoleSeparator = " | "

Variables

View Source
var (
	Debug     = currentLog.Debug
	Debugf    = currentLog.Debugf
	Debugw    = currentLog.Debugw
	Info      = currentLog.Info
	Infof     = currentLog.Infof
	Infow     = currentLog.Infow
	Warn      = currentLog.Warn
	Warnf     = currentLog.Warnf
	Warnw     = currentLog.Warnw
	Error     = currentLog.Error
	Errorf    = currentLog.Errorf
	Errorw    = currentLog.Errorw
	DPanic    = currentLog.DPanic
	DPanicf   = currentLog.DPanicf
	DPanicw   = currentLog.DPanicw
	Panic     = currentLog.Panic
	Panicf    = currentLog.Panicf
	Panicw    = currentLog.Panicw
	Fatal     = currentLog.Fatal
	Fatalf    = currentLog.Fatalf
	Fatalw    = currentLog.Fatalw
	ZapDebug  = currentLog.ZapDebug
	ZapInfo   = currentLog.ZapInfo
	ZapWarn   = currentLog.ZapWarn
	ZapError  = currentLog.ZapError
	ZapDPanic = currentLog.ZapDPanic
	ZapPanic  = currentLog.ZapPanic
	ZapFatal  = currentLog.ZapFatal
	Sync      = currentLog.Sync
)
View Source
var (
	AddStacktrace = zap.AddStacktrace
	AddCaller     = zap.AddCaller
	AddCallerSkip = zap.AddCallerSkip
)
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 ResetCurrentLog

func ResetCurrentLog(l *Logger)

Types

type Field

type Field = zapcore.Field

type Format

type Format int8
const (
	ConsoleFormat Format = iota
	JsonFormat
)

func ParseFormat

func ParseFormat(format string) Format

type Level

type Level = zapcore.Level
const (
	DebugLevel  Level = zap.DebugLevel
	InfoLevel   Level = zap.InfoLevel
	WarnLevel   Level = zap.WarnLevel
	ErrorLevel  Level = zap.ErrorLevel
	DPanicLevel Level = zap.DPanicLevel
	PanicLevel  Level = zap.PanicLevel
	FatalLevel  Level = zap.FatalLevel
)

func ParseLevel

func ParseLevel(level string) Level

type LevelEnablerFunc

type LevelEnablerFunc func(lvl Level) bool

type Logger

type Logger struct {
	ZapLogger        *zap.Logger
	ZapSugaredLogger *zap.SugaredLogger
}

func CurrentLog

func CurrentLog() *Logger

func New

func New(writer io.Writer, format Format, level Level, addCaller bool, opts ...Option) *Logger

func NewTee

func NewTee(tops []TeeOption, addCaller bool, opts ...Option) *Logger

func NewTeeWithRotate

func NewTeeWithRotate(tops []TeeWithRotateOption, addCaller bool, opts ...Option) *Logger

func (*Logger) DPanic

func (l *Logger) DPanic(args ...interface{})

func (*Logger) DPanicf

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

func (*Logger) DPanicw

func (l *Logger) DPanicw(msg string, keysAndValues ...interface{})

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

func (*Logger) Debugf

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

func (*Logger) Debugw

func (l *Logger) Debugw(msg string, keysAndValues ...interface{})

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

func (*Logger) Errorf

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

func (*Logger) Errorw

func (l *Logger) Errorw(msg string, keysAndValues ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

func (*Logger) Fatalf

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

func (*Logger) Fatalw

func (l *Logger) Fatalw(msg string, keysAndValues ...interface{})

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

func (*Logger) Infof

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

func (*Logger) Infow

func (l *Logger) Infow(msg string, keysAndValues ...interface{})

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

func (*Logger) Panicf

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

func (*Logger) Panicw

func (l *Logger) Panicw(msg string, keysAndValues ...interface{})

func (*Logger) Sync

func (l *Logger) Sync() error

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

func (*Logger) Warnf

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

func (*Logger) Warnw

func (l *Logger) Warnw(msg string, keysAndValues ...interface{})

func (*Logger) ZapDPanic

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

func (*Logger) ZapDebug

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

func (*Logger) ZapError

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

func (*Logger) ZapFatal

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

func (*Logger) ZapInfo

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

func (*Logger) ZapPanic

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

func (*Logger) ZapWarn

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

type Option

type Option = zap.Option

type TeeOption

type TeeOption struct {
	W   io.Writer
	Lef LevelEnablerFunc
	F   Format
}

type TeeWithRotateOption

type TeeWithRotateOption struct {
	Filename   string
	MaxSize    int  // the maximum size in megabytes of the log file before it gets rotated
	MaxAge     int  // the maximum number of days to retain old log files based on the timestamp encoded in their filename
	MaxBackups int  // the maximum number of old log files to retain
	Compress   bool // the rotated log files should be compressed or not
	Lef        LevelEnablerFunc
	F          Format
}

Jump to

Keyboard shortcuts

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