readme: dont use printf

This commit is contained in:
Simon Eskildsen 2014-03-06 21:26:05 -05:00
parent 52eb6b2fe6
commit 8492d88e94
1 changed files with 7 additions and 3 deletions

View File

@ -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) {