zaplog

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DPanic

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

func Debug

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

func Error

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

func Fatal

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

func Info

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

func Init

func Init(cfg *ZapLogConfig)

func NewZapLog

func NewZapLog(cfg *ZapLogConfig) *zap.Logger

NewZapLog 创建zap日志实例

func Panic

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

func Warn

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

func With

func With(fields ...zap.Field) *zap.Logger

func WithCtx

func WithCtx(ctx context.Context) *zap.Logger

WithCtx 从上下文里提取key信息, 比如trace_id。这些信息会自动的加入log里

func WithOptions

func WithOptions(opts ...zap.Option) *zap.Logger

Types

type ZapLogConfig

type ZapLogConfig struct {
	// 指定日志的文件名
	Filename string `json:"filename" yaml:"filename"`
	// 日志级别, 可选值为 debug、info、warn、error、dpanic、panic、fatal
	Level string `json:"level" yaml:"level"`
	// 日志格式, 可选值为 json 或 console
	Format string `json:"format" yaml:"format"`
	MaxAge int    `json:"max_age" yaml:"max_age"`
	// 指定日志文件的最大值
	MaxSize int `json:"max_size" yaml:"max_size"`
	// 指定日志文件的备份
	MaxBackups int  `json:"max_backups" yaml:"max_backups"`
	Compress   bool `json:"compress" yaml:"compress"`
	// 上下文里提取的key信息, 比如trace_id。这些信息会自动的加入log里
	CtxKeys []string `json:"ctx_keys" yaml:"ctx_keys"`
}

ZapLogConfig zap日志配置参数

Jump to

Keyboard shortcuts

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