log

package module
v0.0.0-...-79ac66d Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 6 Imported by: 0

README

log

介绍

封装生产可复用的zap日志框架,集成lumberjack日志回滚功能

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultLoggerConfig = &LoggerConfig{
		Level:    "info",
		TextMode: true,
		Console:  true,
	}
)

Functions

func AddOperationID

func AddOperationID(l *zap.Logger, key string) *zap.Logger

func GenRandomID

func GenRandomID(length int) (string, error)

生成安全的随机ID

func InitLogger

func InitLogger(conf *LoggerConfig) (err error)

InitLogger 初始化Logger

func SetIdGenFunc

func SetIdGenFunc(f idGenFunc)

Types

type LoggerConfig

type LoggerConfig struct {
	Level      string `yaml:"level" json:"level"`             // debug, info, warn, error, dpanic, panic, fatal
	TextMode   bool   `yaml:"text_mode" json:"text_mode"`     // 是否以文本格式输出日志,默认为json格式输出
	Console    bool   `yaml:"console" json:"console"`         // 是否输出到终端,在未指定日志文件名,默认输出到终端
	Path       string `yaml:"path" json:"path"`               // 日志文件存放路径
	MaxSize    int    `yaml:"max_size" json:"max_size"`       // megabytes
	MaxBackups int    `yaml:"max_backups" json:"max_backups"` // 保留旧文件的最大个数
	MaxAge     int    `yaml:"max_age" json:"max_age"`         // 天数
	Compress   bool   `yaml:"compress" json:"compress"`       // 是否压缩/归档旧文件
}

Jump to

Keyboard shortcuts

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