2021-02-17 11:14:47 +02:00
|
|
|
# Log
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
### Structured logging
|
|
|
|
|
2021-04-30 19:15:30 +02:00
|
|
|
```go
|
2021-05-17 10:34:28 +02:00
|
|
|
Logger logger = log.MultiLogger(log.NewStdLogger(os.Stdout), syslog.NewLogger())
|
2021-03-14 09:36:00 +02:00
|
|
|
|
2021-05-17 10:34:28 +02:00
|
|
|
logger = log.With(logger,
|
|
|
|
"service.name", "hellworld",
|
|
|
|
"service.version", "v1.0.0",
|
|
|
|
"ts", log.DefaultTimestamp,
|
|
|
|
"caller", log.DefaultCaller,
|
2021-04-30 19:15:30 +02:00
|
|
|
)
|
|
|
|
|
2021-05-17 10:34:28 +02:00
|
|
|
logger.Log(log.LevelInfo, "key", "value")
|
2021-04-30 19:15:30 +02:00
|
|
|
|
2021-05-17 10:34:28 +02:00
|
|
|
Helper helper = log.NewHelper(logger)
|
|
|
|
helper.Log(log.LevelInfo, "key", "value")
|
|
|
|
helper.Info("info message")
|
|
|
|
helper.Infof("info %s", "message")
|
|
|
|
helper.Infow("key", "value")
|
2021-02-17 11:14:47 +02:00
|
|
|
```
|