xlog

package
v0.0.0-...-84a7560 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

README

logger

这里应该做好对各种 logger 的 new 操作 日志分割方案 集成 ctx

以及一些高级用法案例

logger 基于 zap logger 进行了一些封装

  • 输出到标准输出 stdout & 其他?
  • 日志分割?
  • 封装 ctx

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenZapLogger

func OpenZapLogger(cfg *ZapCFG) (*zap.Logger, error)

Types

type Fields

type Fields struct {
	App         string                 `json:"app" mapstructure:"app"`
	ExtraFields map[string]interface{} `json:"extra_fields" mapstructure:"extra_fields"`
}

type Lumberjack

type Lumberjack struct {
	LogPath    string `json:"log_path" mapstructure:"log_path"`       // 日志文件路径,默认 os.TempDir()
	MaxSize    int    `json:"max_size" mapstructure:"max_size"`       // 日志保存大小,默认 100 MB
	MaxBackups int    `json:"max_backups" mapstructure:"max_backups"` // 日志备份数
	MaxAge     int    `json:"max_age" mapstructure:"max_age"`         // 最长保存天数
	Compress   bool   `json:"compress" mapstructure:"compress"`       // 是否压缩,默认不压缩
}

type ZapCFG

type ZapCFG struct {
	Development       bool `json:"development" mapstructure:"development"` // 是否开发环境
	Debug             bool `json:"debug" mapstructure:"debug"`             // 是否 debug
	Sample            bool `json:"sample" mapstructure:"sample"`           // 是否采样,默认zap是采样的,在生产环境设置为false,关闭采样
	CallerSkip        int  `json:"caller_skip" mapstructure:"caller_skip"` // callerSkip 打印文件和行号
	DisableStackTrace bool `json:"disable_stack_trace" mapstructure:"disable_stack_trace"`

	Fields     *Fields     `json:"fields" mapstructure:"fields"`         // 携带一些自定义信息
	Lumberjack *Lumberjack `json:"lumberjack" mapstructure:"lumberjack"` // 日志分割 options
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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