You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
kratos/log
包子 b4dd478bc9
update log/readme.md (#1085)
4 years ago
..
README.md update log/readme.md (#1085) 4 years ago
filter.go fix log filter (#1056) 4 years ago
filter_test.go fix 4 years ago
helper.go add log fatal level (#1067) 4 years ago
helper_test.go add ctx for logger (#998) 4 years ago
level.go add log fatal level (#1067) 4 years ago
log.go add ctx for logger (#998) 4 years ago
log_test.go log: add level printer (#918) 4 years ago
std.go fix log filter (#1056) 4 years ago
std_test.go log: add level printer (#918) 4 years ago
value.go fix 4 years ago
value_test.go log: add level printer (#918) 4 years ago

README.md

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(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")