Documentation
¶
Index ¶
- func Configure(opts Options)
- func ConfigureFromEnv()
- func Debugf(c context.Context, format string, args ...interface{})
- func Error(c context.Context, args ...interface{})
- func ErrorWithFields(c context.Context, err error, fields logrus.Fields)
- func Errorf(c context.Context, format string, args ...interface{})
- func Fatalf(c context.Context, format string, args ...interface{})
- func GetLogger(c context.Context) *logrus.Entry
- func Info(c context.Context, args ...interface{})
- func Infof(c context.Context, format string, args ...interface{})
- func LevelFromString(s string) logrus.Level
- func Warn(c context.Context, args ...interface{})
- func Warnf(c context.Context, format string, args ...interface{})
- type CustomFormatter
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Configure ¶ added in v0.1.4
func Configure(opts Options)
Configure 使用给定参数重新配置全局日志。
优先级(低 → 高):
- Options 传入的取值(通常来自 config.yml 的 log 段)
- LOG_LEVEL / LOG_PATH 环境变量
可重复调用(例如加载 config.yml 之后),每次都会关闭旧的日志文件句柄。
func ConfigureFromEnv ¶
func ConfigureFromEnv()
ConfigureFromEnv 使用环境变量重新配置日志(向后兼容入口)。 这允许在 main() 中加载 .env 后,让 LOG_LEVEL / LOG_PATH 立即生效。
func ErrorWithFields ¶
ErrorWithFields 输出带有额外字段的错误级别日志
func LevelFromString ¶ added in v0.1.4
LevelFromString 把字符串解析为 logrus.Level。 支持 trace/debug/info/warn(warning)/error/fatal/panic; 空值或未识别的取值返回默认级别。
Types ¶
type CustomFormatter ¶
type CustomFormatter struct {
ForceColor bool // 是否强制使用颜色,即使在非终端环境下
}
Click to show internal directories.
Click to hide internal directories.