logger

package
v0.0.0-...-ba87f1b Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(c *Config) log.Logger

NewLogger 配置zap日志,将zap日志库引入

func WithModule

func WithModule(logger log.Logger, module string) log.Logger

WithModule 为logger添加module键值对 module命名规范: "[组件]/[层]/[服务名]" 例如: "redis/data/krathub-service", "auth/biz/krathub-service"

Types

type Config

type Config struct {
	Env        string
	Level      int32
	Filename   string
	MaxSize    int32
	MaxBackups int32
	MaxAge     int32
	Compress   bool
}

type GormLogger

type GormLogger struct {
	ZapLogger     *zap.Logger
	SlowThreshold time.Duration
}

GormLogger 操作对象,实现 gormlogger.Interface

func (GormLogger) Error

func (l GormLogger) Error(ctx context.Context, str string, args ...any)

Error 实现 gormlogger.Interface 的 Error 方法

func (GormLogger) Info

func (l GormLogger) Info(ctx context.Context, str string, args ...any)

Info 实现 gormlogger.Interface 的 Info 方法

func (GormLogger) LogMode

LogMode 实现 gormlogger.Interface 的 LogMode 方法

func (GormLogger) Trace

func (l GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace 实现 gormlogger.Interface 的 Trace 方法

func (GormLogger) Warn

func (l GormLogger) Warn(ctx context.Context, str string, args ...any)

Warn 实现 gormlogger.Interface 的 Warn 方法

type ZapLogger

type ZapLogger struct {
	Sync func() error
	// contains filtered or unexported fields
}

func (*ZapLogger) GetGormLogger

func (l *ZapLogger) GetGormLogger(module string) GormLogger

GetGormLogger 获取Gorm日志适配器

func (*ZapLogger) Log

func (l *ZapLogger) Log(level log.Level, keyvals ...any) error

Log 实现log接口

Jump to

Keyboard shortcuts

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