logger

package
v2.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 12 Imported by: 0

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

func Any(key string, value any) zap.Field

func Args

func Args(args ...any) zap.Field

func Binary

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

func Bool

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

func Bools

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

func BytesString

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

func BytesStrings

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

func Cmd

func Cmd(cmd string) zap.Field

func Code added in v2.0.2

func Code(code int) zap.Field

func Consumer added in v2.0.12

func Consumer(consumer string) zap.Field

func Data

func Data(data []byte) zap.Field

func Duration

func Duration(duration time.Duration) zap.Field

func Error

func Error(err error) zap.Field

func Event

func Event(name string) zap.Field

func Headers added in v2.0.7

func Headers(headers map[string]string) zap.Field

func Id

func Id(id int64) zap.Field

func InitZapWithOption

func InitZapWithOption(conf Option, zapOpts ...zap.Option) error

func Int

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

func Int16

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

func Int16s

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

func Int32

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

func Int32s

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

func Int64

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

func Int64s

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

func Int8

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

func Ints

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

func Ip

func Ip(ip string) zap.Field

func IsLevel

func IsLevel(level zapcore.Level) bool

func Key

func Key(key string) zap.Field

func Method

func Method(method string) zap.Field

func Mid

func Mid(mid string) zap.Field

func Offset

func Offset(oft string) zap.Field

func Params

func Params(params ...any) zap.Field

func Path

func Path(path string) zap.Field

func Pid

func Pid(pid int) zap.Field

func Signal

func Signal(sig syscall.Signal) zap.Field

func Size

func Size(size int64) zap.Field

func Sql added in v2.0.2

func Sql(sql string) zap.Field

func String

func String(key, value string) zap.Field

func Strings

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

func Time

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

func Times

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

func Token added in v2.0.2

func Token(token string) zap.Field

func Topic added in v2.0.12

func Topic(topic string) zap.Field

func TraceId

func TraceId(traceId string) zap.Field

func Uint

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

func Uint16

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

func Uint16s

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

func Uint32

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

func Uint32s

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

func Uint64

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

func Uint64s

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

func Uint8

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

func Uint8s

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

func Uints

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 any) zap.Field

func ZapDPanic

func ZapDPanic(msg string, fields ...zap.Field)

func ZapDebug

func ZapDebug(msg string, fields ...zap.Field)

func ZapError

func ZapError(msg string, fields ...zap.Field)

func ZapFatal

func ZapFatal(msg string, fields ...zap.Field)

func ZapInfo

func ZapInfo(msg string, fields ...zap.Field)

func ZapPanic

func ZapPanic(msg string, fields ...zap.Field)

func ZapSync

func ZapSync() error

func ZapWarn

func ZapWarn(msg string, fields ...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"`
	// 日志目录,path为空表示使用日志输出到控制台
	Path string `json:"path" yaml:"path"`
	// 定时检测文件时间间隔,单位秒,配置小于0的值表示禁用,默认5秒
	TickSecond int32 `json:"tickSecond" yaml:"tickSecond"`
	// 日志文件最长保留时间,单位天,配置小于0表示永久保留,默认7天
	MaxDays int `json:"maxDays" yaml:"maxDays"`
	// 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