log

package
v0.0.0-...-f33d96e Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(ProvideLogger)

ProviderSet is the Wire provider set for the log package.

Functions

func Debug

func Debug(args ...interface{})

func Debugw

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

func Error

func Error(args ...interface{})

func Errorw

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

func Fatal

func Fatal(args ...interface{})

func Fatalw

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

func GetLevel

func GetLevel() zapcore.Level

GetLevel 获取当前日志级别

func GetLogger

func GetLogger() *zap.SugaredLogger

GetLogger 获取全局 zap.Logger 实例

func Info

func Info(args ...interface{})

func Infow

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

func Init

func Init(conf *Conf) error

Init 初始化全局日志实例(便捷方法)

func MustInit

func MustInit(conf *Conf)

MustInit 初始化全局日志实例,失败则 panic

func NewLog

func NewLog(conf *Conf) (*zap.Logger, error)

NewLog initializes the logger and returns a zap.Logger.

func Sync

func Sync() error

Sync 刷新缓冲区

func Warn

func Warn(args ...interface{})

func Warnw

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

Types

type Conf

type Conf struct {
	Output       string
	Path         string
	Filename     string // 日志文件名,为空时使用默认值
	Level        string
	KeepHours    int // 日志保留天数(改为导出)
	RotateSize   int // 单个日志文件最大大小(MB)
	RotateNum    int // 保留的日志文件数量
	KafkaBrokers string
	KafkaTopic   string
}

Conf holds Conf configuration options.

func SetDefaults

func SetDefaults() *Conf

SetDefaults 返回默认配置

func (*Conf) Validate

func (c *Conf) Validate() error

Validate 验证配置

type Logger

type Logger struct {
	Log *zap.SugaredLogger
}

func ProvideLogger

func ProvideLogger(conf *Conf) (*Logger, error)

ProvideLogger 提供 Logger 实例

type Option

type Option func(*Logger)

Jump to

Keyboard shortcuts

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