zaplogger

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 9 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLevel = errors.New("invalid Level")
)

Functions

func Addr

func Addr(addr string) zap.Field

func Any added in v1.2.24

func Any(key string, value interface{}) zap.Field

func Args added in v1.2.15

func Args(args ...interface{}) zap.Field

func Binary added in v1.2.24

func Binary(key string, value []byte) zap.Field

func Bool added in v1.2.24

func Bool(key string, value bool) zap.Field

func Bools added in v1.2.24

func Bools(key string, value []bool) zap.Field

func BytesString added in v1.2.24

func BytesString(key string, value []byte) zap.Field

func BytesStrings added in v1.2.24

func BytesStrings(key string, value [][]byte) zap.Field

func Cmd added in v1.2.24

func Cmd(cmd string) zap.Field

func Data

func Data(data []byte) zap.Field

func Duration added in v1.2.15

func Duration(duration time.Duration) zap.Field

func Error

func Error(err error) zap.Field

func Event

func Event(name string) zap.Field

func Id added in v1.2.15

func Id(id int64) zap.Field

func Int added in v1.2.24

func Int(key string, value int) zap.Field

func Int16 added in v1.2.24

func Int16(key string, value int16) zap.Field

func Int16s added in v1.2.24

func Int16s(key string, value []int16) zap.Field

func Int32 added in v1.2.24

func Int32(key string, value int32) zap.Field

func Int32s added in v1.2.24

func Int32s(key string, value []int32) zap.Field

func Int64 added in v1.2.24

func Int64(key string, value int64) zap.Field

func Int64s added in v1.2.24

func Int64s(key string, value []int64) zap.Field

func Int8 added in v1.2.24

func Int8(key string, value int8) zap.Field

func Ints added in v1.2.24

func Ints(key string, value []int) zap.Field

func Ip

func Ip(ip string) zap.Field

func Key added in v1.2.24

func Key(key string) zap.Field

func Method added in v1.2.15

func Method(method string) zap.Field

func Mid

func Mid(mid string) zap.Field

func Offset added in v1.2.24

func Offset(oft string) zap.Field

func Params added in v1.2.15

func Params(params ...interface{}) zap.Field

func Path added in v1.2.15

func Path(path string) zap.Field

func Size added in v1.2.24

func Size(size int64) zap.Field

func String added in v1.2.24

func String(key, value string) zap.Field

func Strings added in v1.2.24

func Strings(key string, value []string) zap.Field

func Time added in v1.2.24

func Time(key string, value time.Time) zap.Field

func Times added in v1.2.24

func Times(key string, value []time.Time) zap.Field

func TraceId

func TraceId(traceId string) zap.Field

func Uint added in v1.2.24

func Uint(key string, value uint) zap.Field

func Uint16 added in v1.2.24

func Uint16(key string, value uint16) zap.Field

func Uint16s added in v1.2.24

func Uint16s(key string, value []uint16) zap.Field

func Uint32 added in v1.2.24

func Uint32(key string, value uint32) zap.Field

func Uint32s added in v1.2.24

func Uint32s(key string, value []uint32) zap.Field

func Uint64 added in v1.2.24

func Uint64(key string, value uint64) zap.Field

func Uint64s added in v1.2.24

func Uint64s(key string, value []uint64) zap.Field

func Uint8 added in v1.2.24

func Uint8(key string, value uint8) zap.Field

func Uint8s added in v1.2.24

func Uint8s(key string, value []uint8) zap.Field

func Uints added in v1.2.24

func Uints(key string, value []uint) zap.Field

func UpdateAt

func UpdateAt(updatedAt int64) zap.Field

func Uri

func Uri(uri string) zap.Field

func Value

func Value(value interface{}) zap.Field

Types

type Logger

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

func NewLogger

func NewLogger(opt Option, opts ...zap.Option) (logger *Logger, err error)

func (*Logger) DPanic

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

DPanic logs are particularly important errors. In development the logger panics after writing the message.

func (*Logger) Debug

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

Debug logs are typically voluminous, and are usually disabled in production.

func (*Logger) Error

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

Error logs are high-priority. If an application is running smoothly, it shouldn't generate any error-level logs.

func (*Logger) Fatal

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

Fatal logs a message, then calls os.Exit(1).

func (*Logger) Info

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

Info is the default logging priority.

func (*Logger) Is

func (l *Logger) Is(level zapcore.Level) bool

Is 判断日志级别

func (*Logger) Panic

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

Panic logs a message, then panics.

func (*Logger) Sync

func (l *Logger) Sync() error

Sync calls the underlying Core's Sync method, flushing any buffered log

entries. Applications should take care to call Sync before exiting.

func (*Logger) Warn

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

Warn logs are more important than Info, but don't need individual human review.

type Option

type Option struct {
	// 日志级别:debug: -1 info:0 warn: 1 error: 2 dpanic: 3 panic: 4 fatal: 5
	Level int8 `json:"level" yaml:"level"`
	// 日志目录,默认路径:/tmp
	Path string `json:"path" yaml:"path"`
	// 定时检测文件时间间隔,单位秒,配置小于0的值表示禁用,默认5秒
	TickSecond int32 `json:"tickSecond" yaml:"tickSecond"`
	// contains filtered or unexported fields
}

func (*Option) WithEncoder

func (opt *Option) WithEncoder(encoder zapcore.Encoder)

func (*Option) WithFlagFunc

func (opt *Option) WithFlagFunc(flag func() string)

type Options

type Options func(o *Option)

Jump to

Keyboard shortcuts

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