etlog is a log component for go.
- Support log level
- Stdout and file appender
- log markers support
- Simple usage
etlog.Log.Info("Hello World")
It will output the log into stdout device(console log).
- Using log config
logger, err := etlog.NewEtLogger(etlog.SetConfigPath("log.yaml"))
if err != nil {
panic(err)
}
logger.Debug("hello")
logger.Info("world")
the log config file please refer to: example/log.yaml
- Using fieds
etlog.Log.WithError(fmt.Errorf("oops")).
WithField("key", "word").
WithField("now", time.Now()).
Error("something wrong happened")
the WithField
method will help you print K-V fields into log.
- Using markers
etlog.Log.WithMarkers("trace").Data("hello world")
Because we support different log handler, to determine which handler the content will be output, we use marker
to
route it. Such as the example, when we use trace
as marker of log, then the content will be processed by handler
marked as trace
.