zap

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LOGGER *zap.Logger // 记录器,使用时,直接引入此包,然后"LOGGER.Debug(msg, fields...)"

)

Functions

func Any

func Any(k string, v interface{}) zapcore.Field

转换 zap.LOGGER.Debut(msg, zap.Any(name1, value1), zap.Any(name2, value2))

func Error

func Error(err error) zapcore.Field

转换 zap.LOGGER.Error(msg, zap.Error(err1), zap.Error(err2))

func PanicIfErr

func PanicIfErr(err error)

Types

type ZapCompressConfig

type ZapCompressConfig struct {
	Enable     bool `mapstructure:"enable" json:"enable" yaml:"enable"`               // 是否开启
	MaxSize    int  `mapstructure:"max-size" json:"MaxSize" yaml:"max-size"`          // 在进行切割之前,日志文件的最大大小(以MB为单位)
	MaxBackups int  `mapstructure:"max-backups" json:"maxBackups" yaml:"max-backups"` // 保留旧文件的最大个数
	MaxAge     int  `mapstructure:"max-age" json:"maxAge" yaml:"max-age"`             // 保留旧文件的最大天数
}

type ZapConfig

type ZapConfig struct {
	Level         string `mapstructure:"level" json:"level" yaml:"level"`                           // 级别
	Format        string `mapstructure:"format" json:"format" yaml:"format"`                        // 输出模式,json/console
	LogInConsole  bool   `mapstructure:"log-in-console" json:"logInConsole" yaml:"log-in-console"`  // 输出控制台
	Prefix        string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`                        // 日志前缀
	TimeFormat    string `mapstructure:"time-format" json:"timeFormat" yaml:"time-format"`          // 时间格式
	ShowLine      bool   `mapstructure:"show-line" json:"showLine" yaml:"show-line"`                // 显示代码行号
	EncodeLevel   string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level"`       // 编码级
	StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key"` // 栈名

	// 文件
	Directory      string            `mapstructure:"directory" json:"directory"  yaml:"directory"`                    // 日志文件夹
	FileNamePrefix string            `mapstructure:"file-name-prefix" json:"fileNamePrefix"  yaml:"file-name-prefix"` // 日志文件前缀
	ZapCompress    ZapCompressConfig `mapstructure:"zap-compress" json:"zapCompress"  yaml:"zap-compress"`            // 日志文件压缩归档
}

func (ZapConfig) Load

func (z ZapConfig) Load()

Jump to

Keyboard shortcuts

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