Update readme at example for Caller() (#76)

* Update readme at example for Caller()
This commit is contained in:
Josh Rendek 2018-06-04 01:57:37 -04:00 committed by Olivier Poitrey
parent dabc72c15b
commit 1a88fbfdd0
1 changed files with 10 additions and 0 deletions

View File

@ -293,6 +293,16 @@ log.Info().Msg("hello world")
log.Logger = log.With().Str("foo", "bar").Logger()
```
### Add file and line number to log
```go
log.Logger = log.With().Caller().Logger()
log.Info().Msg("hello world")
// Output: {"level": "info", "message": "hello world", "caller": "/go/src/your_project/some_file:21"}
```
### Thread-safe, lock-free, non-blocking writer
If your writer might be slow or not thread-safe and you need your log producers to never get slowed down by a slow writer, you can use a `diode.Writer` as follow: