dailyxlog

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(template string, args ...interface{})

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

func Error

func Error(template string, args ...interface{})

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

func Fatal

func Fatal(template string, args ...interface{})

func Fatalw

func Fatalw(msg string, keysAndValues ...interface{})

func GetSugar

func GetSugar() *zap.SugaredLogger

GetSugar 供外部获取原始的 SugaredLogger,主要为了实现特定功能如 WithContext

func Info

func Info(template string, args ...interface{})

func Infow

func Infow(msg string, keysAndValues ...interface{})

func New

func New(cfg Config)

New 全局初始化函数,供业务在启动时调用

func Warn

func Warn(template string, args ...interface{})

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Types

type Config

type Config struct {
	Level      string // debug, info, warn, error
	Stdout     bool   // 是否输出到控制台
	Dir        string // 基础日志目录
	Filename   string // 基础日志文件名
	MaxSize    int    // 单个文件最大大小 (MB)
	MaxBackups int    // 最大旧文件保留个数
	MaxAge     int    // 最大保留天数
	Compress   bool   // 是否对旧日志压缩
}

Config 定义完整的日志配置

type DailyLumberjack

type DailyLumberjack struct {
	// contains filtered or unexported fields
}

DailyLumberjack 包装 lumberjack.Logger,实现按日期生成目录+文件尺寸切割双维度

func NewDailyLumberjack

func NewDailyLumberjack(cfg Config) *DailyLumberjack

NewDailyLumberjack 创建一个新的 DailyLumberjack 实例

func (*DailyLumberjack) Close

func (l *DailyLumberjack) Close() error

func (*DailyLumberjack) Sync

func (l *DailyLumberjack) Sync() error

func (*DailyLumberjack) Write

func (l *DailyLumberjack) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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