Merge pull request #45 from aybabtme/export-package-level-log-funcs

Export package func to a standard logger.
This commit is contained in:
Simon Eskildsen
2014-07-26 20:48:56 -04:00
7 changed files with 151 additions and 57 deletions
+11 -4
View File
@@ -81,6 +81,13 @@ func main() {
}
```
#### Package logging
Alike the stdlib logger, logrus exposes functions that you can use to log
to a default global logger. This is convenient to avoid passing a
`logrus.Logger` thorough your app's packages; you can simply setup `logrus
from your main package and use the package function directly accross your app.
#### Fields
Logrus encourages careful, structured logging though logging fields instead of
@@ -94,7 +101,7 @@ log = logrus.New()
log.WithFields(logrus.Fields{
"event": event,
"topic": topic,
"key": key
"key": key,
}).Fatal("Failed to send event")
```
@@ -140,9 +147,9 @@ func (hook *AirbrakeHook) Fire(entry *logrus.Entry) error {
// `Levels()` returns a slice of `Levels` the hook is fired for.
func (hook *AirbrakeHook) Levels() []logrus.Level {
return []logrus.Level{
logrus.Error,
logrus.Fatal,
logrus.Panic,
logrus.ErrorLevel,
logrus.FatalLevel,
logrus.PanicLevel,
}
}
```