zaplogger

package
v1.2.13 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 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 Data

func Data(data []byte) zap.Field

func Error

func Error(err error) zap.Field

func Event

func Event(name string) zap.Field

func Ip

func Ip(ip string) zap.Field

func Mid

func Mid(mid string) zap.Field

func TraceId

func TraceId(traceId string) 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