log

package module
v0.0.0-...-554d713 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 6 Imported by: 0

README

log

开箱即用的zap logger,基于tony bai的文章的demo https://tonybai.com/2021/07/14/uber-zap-advanced-usage/

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WithCaller    = zap.WithCaller
	AddStacktrace = zap.AddStacktrace
	AddCallerSkip = zap.AddCallerSkip // 打印文件skip,多个skip则相加
)
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.Int32
	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.Uintptr
	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
)
View Source
var (
	Info   = std.l.Info
	Warn   = std.l.Warn
	Error  = std.l.Error
	DPanic = std.l.DPanic
	Panic  = std.l.Panic
	Fatal  = std.l.Fatal
	Debug  = std.l.Debug

	SugarDebug  = sugarStd.Debug
	SugarInfo   = sugarStd.Info
	SugarWarn   = sugarStd.Warn
	SugarError  = sugarStd.Error
	SugarDPanic = sugarStd.DPanic
	SugarPanic  = sugarStd.Panic
	SugarFatal  = sugarStd.Fatal

	SugarDebugf  = sugarStd.Debugf
	SugarInfof   = sugarStd.Infof
	SugarWarnf   = sugarStd.Warnf
	SugarErrorf  = sugarStd.Errorf
	SugarDPanicf = sugarStd.DPanicf
	SugarPanicf  = sugarStd.Panicf
	SugarFatalf  = sugarStd.Fatalf

	SugarDebugw  = sugarStd.Debugw
	SugarInfow   = sugarStd.Infow
	SugarWarnw   = sugarStd.Warnw
	SugarErrorw  = sugarStd.Errorw
	SugarDPanicw = sugarStd.DPanicw
	SugarPanicw  = sugarStd.Panicw
	SugarFatalw  = sugarStd.Fatalw
)

Functions

func ResetDefault

func ResetDefault(l *Logger)

func Sync

func Sync() error

Types

type Field

type Field = zap.Field

type Level

type Level = zapcore.Level
const (
	InfoLevel   Level = zap.InfoLevel
	WarnLevel   Level = zap.WarnLevel
	ErrorLevel  Level = zap.ErrorLevel
	DPanicLevel Level = zap.DPanicLevel
	PanicLevel  Level = zap.PanicLevel // log msg, then panic
	FatalLevel  Level = zap.FatalLevel // log msg, then calls os.Exit(1)
	DebugLevel  Level = zap.DebugLevel
)

type LevelEnableFunc

type LevelEnableFunc func(lvl Level) bool

type Logger

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

func Default

func Default() *Logger

func New

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

func NewTee

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

func NewTeeWithRotate

func NewTeeWithRotate(topts []TeeOption, opts ...Option) *Logger

func (*Logger) Sync

func (l *Logger) Sync() error

type Option

type Option = zap.Option

type RotateOption

type RotateOption struct {
	MaxSize    int
	MaxAge     int
	MaxBackups int
	Compress   bool
}

type TeeOption

type TeeOption struct {
	Filename string
	Lef      LevelEnableFunc
	Ropt     RotateOption
}

Jump to

Keyboard shortcuts

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