Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Captain1/log

Repository files navigation

logger

License

  1. 包名: github.com/fuyibing/log/v2.
  2. 版本: v2

本包在导入后, 扫描 tmp/log.yamlconfig/log.yaml 并初始化, 详细配置参见本包的 config/log.yaml 注释.

通用用法.

log.Info("message.")
log.Infof("message %d: %s.", 1, "parse", "example")

带请求链

ctx := log.NewContext()
log.Debugfc(ctx, "debug fc")
log.Infofc(ctx, "info fc")
log.Warnfc(ctx, "warn fc")
log.Errorfc(ctx, "error fc")

在IRIS框架中

首先通过中间件, 在入口注册请求链.

log.BindRequest(iris.Request())

在IRIS框架中使用.

ctx := iris.Request().Context()
log.Debugfc(ctx, "debug fc")
log.Infofc(ctx, "info fc")
log.Warnfc(ctx, "warn fc")
log.Errorfc(ctx, "error fc")

自定义日志处理.

log.Config.SetHandler(func(line interfaces.LineInterface) {
 println("handler: ", line.SpanVersion(), line.Content())
})
ctx := log.NewContext()
log.Debugfc(ctx, "debug fc")
log.Infofc(ctx, "info fc")
log.Warnfc(ctx, "warn fc")
log.Errorfc(ctx, "error fc")

About

go logger

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%

AltStyle によって変換されたページ (->オリジナル) /