logger

package
v0.0.0-...-04efeb6 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, msg string, fields ...zap.Field)

func Error

func Error(ctx context.Context, msg string, fields ...zap.Field)

func Fatal

func Fatal(ctx context.Context, msg string, fields ...zap.Field)

func Info

func Info(ctx context.Context, msg string, fields ...zap.Field)

func InitLogger

func InitLogger(cfg *config.LoggerConfig) error

InitLogger 初始化全局日志实例,配置从外部传入

func SysDebug

func SysDebug(msg string, fields ...zap.Field)

func SysError

func SysError(msg string, fields ...zap.Field)

func SysFatal

func SysFatal(msg string, fields ...zap.Field)

func SysInfo

func SysInfo(msg string, fields ...zap.Field)

func SysLog

func SysLog(msg string, fields ...zap.Field)

func SysWarn

func SysWarn(msg string, fields ...zap.Field)

func ToZapField

func ToZapField(key string, value interface{}) zap.Field

ToZapField 根据 value 的具体类型将 key-value 对转换为 zap.Field

func ToZapFields

func ToZapFields(data map[string]interface{}) []zap.Field

ToZapFields 将 map[string]interface{} 中的所有键值对转换为 zap.Field 切片

func Warn

func Warn(ctx context.Context, msg string, fields ...zap.Field)

Types

type Logger

type Logger interface {
	Debug(ctx context.Context, msg string, fields ...zap.Field)
	Info(ctx context.Context, msg string, fields ...zap.Field)
	Warn(ctx context.Context, msg string, fields ...zap.Field)
	Error(ctx context.Context, msg string, fields ...zap.Field)
	Fatal(ctx context.Context, msg string, fields ...zap.Field)
}

Logger 定义了日志接口,调用方只需依赖此接口

func GetLogger

func GetLogger() Logger

GetLogger 返回全局日志实例

Jump to

Keyboard shortcuts

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