log

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 8 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 (
	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
)
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
)

Functions

func Debug

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

func Error

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

func Fatal

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

func Info

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

func NewProductionRotateBySize added in v1.2.2

func NewProductionRotateBySize(filename string) io.Writer

NewProductionRotateBySize 创建按大小轮转的 io.Writer

func NewProductionRotateByTime added in v1.2.2

func NewProductionRotateByTime(filename string) io.Writer

NewProductionRotateByTime 创建按时间轮转的 io.Writer

func NewRotateBySize added in v1.2.2

func NewRotateBySize(cfg *RotateConfig) io.Writer

func NewRotateByTime added in v1.2.2

func NewRotateByTime(cfg *RotateConfig) io.Writer

func Panic

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

func ReplaceDefault

func ReplaceDefault(l *Logger)

替换包内置的logger对象

func SetLevel

func SetLevel(level Level)

包方法 使用内置的logger对象完成操作

func Sync

func Sync() error

func Warn

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

Types

type Field

type Field = zap.Field

type Level

type Level = zapcore.Level

type LevelEnablerFunc added in v1.2.0

type LevelEnablerFunc func(Level) bool

type Logger

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

定义日志结构体

func Default

func Default() *Logger

返回包内置的logger对象

func New

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

定义Logger构造方法

func NewTee added in v1.2.0

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

func (*Logger) Debug

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

Logger对象相关方法

func (*Logger) Error

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

func (*Logger) Fatal

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

func (*Logger) Info

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

func (*Logger) Panic

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

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

设置输出级别

func (*Logger) Sync

func (l *Logger) Sync() error

func (*Logger) Warn

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

type Option

type Option = zap.Option

type RotateConfig added in v1.2.2

type RotateConfig struct {
	// 共用配置
	Filename string // 完整文件名
	MaxAge   int    // 保留旧日志文件的最大天数

	// 按时间轮转配置
	RotationTime time.Duration // 日志文件轮转时间

	// 按大小轮转配置
	MaxSize    int  // 日志文件最大大小(MB)
	MaxBackups int  // 保留日志文件的最大数量
	Compress   bool // 是否对日志文件进行压缩归档
	LocalTime  bool // 是否使用本地时间,默认 UTC 时间
}

func NewProductionRotateConfig added in v1.2.2

func NewProductionRotateConfig(filename string) *RotateConfig

type TeeOption added in v1.2.0

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