forked from mirror/logrus
readme: dont use printf
This commit is contained in:
parent
52eb6b2fe6
commit
8492d88e94
10
README.md
10
README.md
|
@ -11,7 +11,7 @@ tracker.
|
||||||
#### Fields
|
#### Fields
|
||||||
|
|
||||||
Logrus encourages careful, informative logging. It encourages the use of logging
|
Logrus encourages careful, informative logging. It encourages the use of logging
|
||||||
fields, instead of long, unparseable error messages. For example, instead of:
|
fields instead of long, unparseable error messages. For example, instead of:
|
||||||
`log.Fatalf("Failed to send event %s to topic %s with key %d")`, you should log
|
`log.Fatalf("Failed to send event %s to topic %s with key %d")`, you should log
|
||||||
the much more discoverable:
|
the much more discoverable:
|
||||||
|
|
||||||
|
@ -27,10 +27,14 @@ log.WithFields(&logrus.Fields{
|
||||||
We've found this API forces you to think about logging in a way that produces
|
We've found this API forces you to think about logging in a way that produces
|
||||||
much more useful logging messages. The `WithFields` call is optional.
|
much more useful logging messages. The `WithFields` call is optional.
|
||||||
|
|
||||||
|
In general, with Logrus using any of the `printf`-family functions should be
|
||||||
|
seen as a hint you want to add a field, however, you can still use the
|
||||||
|
`printf`-family functions with Logrus.
|
||||||
|
|
||||||
#### Hooks
|
#### Hooks
|
||||||
|
|
||||||
You can add hooks for logging levels. For example to send errors, to an
|
You can add hooks for logging levels. For example to send errors to an exception
|
||||||
exception tracking service:
|
tracking service:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
log.AddHook("error", func(entry logrus.Entry) {
|
log.AddHook("error", func(entry logrus.Entry) {
|
||||||
|
|
Loading…
Reference in New Issue