Help us shape the future of Go! Take the 2026 Go Developer Survey

logger

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureFromEnv

func ConfigureFromEnv()

ConfigureFromEnv 重新从环境变量应用日志配置。 这允许在 main() 中加载 .env 后,让 LOG_LEVEL / LOG_PATH 立即生效。

func Debugf

func Debugf(c context.Context, format string, args ...interface{})

Debugf 使用格式化字符串输出调试级别的日志

func Error

func Error(c context.Context, args ...interface{})

Error 输出错误级别的日志

func ErrorWithFields

func ErrorWithFields(c context.Context, err error, fields logrus.Fields)

ErrorWithFields 输出带有额外字段的错误级别日志

func Errorf

func Errorf(c context.Context, format string, args ...interface{})

Errorf 使用格式化字符串输出错误级别的日志

func Fatalf

func Fatalf(c context.Context, format string, args ...interface{})

Fatalf 使用格式化字符串输出致命级别的日志并退出程序

func GetLogger

func GetLogger(c context.Context) *logrus.Entry

GetLogger 获取日志实例

func Info

func Info(c context.Context, args ...interface{})

Info 输出信息级别的日志

func Infof

func Infof(c context.Context, format string, args ...interface{})

Infof 使用格式化字符串输出信息级别的日志

func Warn

func Warn(c context.Context, args ...interface{})

Warn 输出警告级别的日志

func Warnf

func Warnf(c context.Context, format string, args ...interface{})

Warnf 使用格式化字符串输出警告级别的日志

Types

type CustomFormatter

type CustomFormatter struct {
	ForceColor bool // 是否强制使用颜色,即使在非终端环境下
}

func (*CustomFormatter) Format

func (f *CustomFormatter) Format(entry *logrus.Entry) ([]byte, error)

Jump to

Keyboard shortcuts

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