在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:inconshreveable/log15开源软件地址:https://github.com/inconshreveable/log15开源编程语言:Go 100.0%开源软件介绍:log15Package log15 provides an opinionated, simple toolkit for best-practice logging in Go (golang) that is both human and machine readable. It is modeled after the Go standard library's Features
VersioningThe API of the master branch of log15 should always be considered unstable. If you want to rely on a stable API, you must vendor the library. Importingimport log "github.com/inconshreveable/log15" Examples// all loggers can have key/value context
srvlog := log.New("module", "app/server")
// all log messages can have key/value context
srvlog.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate)
// child loggers with inherited context
connlog := srvlog.New("raddr", c.RemoteAddr())
connlog.Info("connection open")
// lazy evaluation
connlog.Debug("ping remote", "latency", log.Lazy{pingRemote})
// flexible configuration
srvlog.SetHandler(log.MultiHandler(
log.StreamHandler(os.Stderr, log.LogfmtFormat()),
log.LvlFilterHandler(
log.LvlError,
log.Must.FileHandler("errors.json", log.JsonFormat())))) Will result in output that looks like this:
Breaking API ChangesThe following commits broke API stability. This reference is intended to help you understand the consequences of updating to a newer version of log15.
FAQThe varargs style is brittle and error prone! Can I have type safety please?Yes. Use srvlog := log.New(log.Ctx{"module": "app/server"})
srvlog.Warn("abnormal conn rate", log.Ctx{"rate": curRate, "low": lowRate, "high": highRate}) Regenerating the CONTRIBUTORS file
LicenseApache |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论