1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-02-21 19:19:32 +02:00
Eng Zer Jun 77b16286f8
refactor: move from io/ioutil to io and os packages (#1633)
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-11-16 13:22:35 +08:00
..
2021-08-31 10:14:57 +08:00
2021-10-21 17:39:33 +08:00
2021-06-24 18:04:55 +08:00
2021-10-21 17:39:33 +08:00
2021-08-31 10:14:57 +08:00
2021-09-22 09:38:33 +08:00
2021-10-21 17:39:33 +08:00
2021-08-31 10:14:57 +08:00
2021-10-21 17:39:33 +08:00
2021-08-31 10:14:57 +08:00

Logger

Usage

Structured logging

logger := log.NewStdLogger(os.Stdout)
// fields & valuer
logger = log.With(logger,
    "service.name", "hellworld",
    "service.version", "v1.0.0",
    "ts", log.DefaultTimestamp,
    "caller", log.DefaultCaller,
)
logger.Log(log.LevelInfo, "key", "value")

// helper
helper := log.NewHelper(logger)
helper.Log(log.LevelInfo, "key", "value")
helper.Info("info message")
helper.Infof("info %s", "message")
helper.Infow("key", "value")

// filter
log := log.NewHelper(log.NewFilter(logger,
	log.FilterLevel(log.LevelInfo),
	log.FilterKey("foo"),
	log.FilterValue("bar"),
	log.FilterFunc(customFilter),
))
log.Debug("debug log")
log.Info("info log")
log.Warn("warn log")
log.Error("warn log")