Documentation
¶
Overview ¶
Package logger 提供基于 logrus 的统一日志封装: 分组、文件滚动、级别热更新、彩色输出、调用位置、ctx trace 前缀。
基本用法:
logger.Info("hello %s", "world")
logger.ErrorCtx(ctx, "call failed: %v", err)
logger.Group("orm").Debugf("[SQL] %s", sql)
Index ¶
- func ConfigChangeListener(event listener.BaseEvent)
- func Debug(format string, v ...any)
- func DebugCtx(ctx context.Context, format string, v ...any)
- func DebugDirect(v ...any)
- func DebugTenant(ctx context.Context, format string, v ...any)
- func Error(format string, v ...any)
- func ErrorCtx(ctx context.Context, format string, v ...any)
- func ErrorDirect(v ...any)
- func Fatal(format string, v ...any)
- func Group(groupNames ...string) *logrus.Logger
- func Info(format string, v ...any)
- func InfoCtx(ctx context.Context, format string, v ...any)
- func InfoDirect(v ...any)
- func InitLog()
- func Record(level, format string, v ...any)
- func SetGlobalLevel(strLevel string)
- func Warn(format string, v ...any)
- func WarnCtx(ctx context.Context, format string, v ...any)
- func WarnDirect(v ...any)
- type StandardFormatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigChangeListener ¶
ConfigChangeListener 配置变更监听:逐 key 事件 + 整文件重载合成事件。
func DebugDirect ¶
func DebugDirect(v ...any)
func DebugTenant ¶ added in v1.0.2
DebugTenant 租户级 debug 日志。 仅当「全局 debug 开启」或「ctx 中租户在 debug_tenant_ids 列表」时输出, 自动带 [TenantId:xxx] [TraceId:xxx] 前缀。
用法:在业务逻辑中需要细粒度排查的地方调用。
logger.DebugTenant(ctx, "processing order: %v", order)
func ErrorDirect ¶
func ErrorDirect(v ...any)
func InfoDirect ¶
func InfoDirect(v ...any)
func WarnDirect ¶
func WarnDirect(v ...any)
Types ¶
type StandardFormatter ¶
type StandardFormatter struct{}
StandardFormatter 统一日志格式:
[2006-01-02 15:04:05] [app-name] LEVEL path:line#func message fields
颜色输出受 logger.color.enable 控制(默认关闭)。
Click to show internal directories.
Click to hide internal directories.