readme: fix examples

This commit is contained in:
Simon Eskildsen 2014-07-26 22:51:23 -04:00
parent 3f50cc7bf7
commit 330e34061e
1 changed files with 15 additions and 15 deletions

View File

@ -55,8 +55,8 @@ import (
) )
func main() { func main() {
log.WithFields(logrus.Fields{ log.WithFields(log.Fields{
"animal": "walrus" "animal": "walrus",
}).Info("A walrus appears") }).Info("A walrus appears")
} }
``` ```
@ -91,17 +91,17 @@ func init() {
} }
func main() { func main() {
log.WithFields(logrus.Fields{ log.WithFields(log.Fields{
"animal": "walrus", "animal": "walrus",
"size": 10, "size": 10,
}).Info("A group of walrus emerges from the ocean") }).Info("A group of walrus emerges from the ocean")
log.WithFields(logrus.Fields{ log.WithFields(log.Fields{
"omg": true, "omg": true,
"number": 122, "number": 122,
}).Warn("The group's number increased tremendously!") }).Warn("The group's number increased tremendously!")
log.WithFields(logrus.Fields{ log.WithFields(log.Fields{
"omg": true, "omg": true,
"number": 100, "number": 100,
}).Fatal("The ice breaks!") }).Fatal("The ice breaks!")
@ -124,9 +124,9 @@ var log = logrus.New()
func main() { func main() {
// The API for setting attributes is a little different than the package level // The API for setting attributes is a little different than the package level
// exported logger. See Godoc. // exported logger. See Godoc.
log.Out = os.Sderr log.Out = os.Stderr
log.WithFields(logrus.Fields{ log.WithFields(log.Fields{
"animal": "walrus", "animal": "walrus",
"size": 10, "size": 10,
}).Info("A group of walrus emerges from the ocean") }).Info("A group of walrus emerges from the ocean")
@ -141,7 +141,7 @@ to send event %s to topic %s with key %d")`, you should log the much more
discoverable: discoverable:
```go ```go
log.WithFields(logrus.Fields{ log.WithFields(log.Fields{
"event": event, "event": event,
"topic": topic, "topic": topic,
"key": key, "key": key,
@ -180,7 +180,7 @@ type AirbrakeHook struct{}
func (hook *AirbrakeHook) Fire(entry *logrus.Entry) error { func (hook *AirbrakeHook) Fire(entry *logrus.Entry) error {
err := airbrake.Notify(entry.Data["error"].(error)) err := airbrake.Notify(entry.Data["error"].(error))
if err != nil { if err != nil {
log.WithFields(logrus.Fields{ log.WithFields(log.Fields{
"source": "airbrake", "source": "airbrake",
"endpoint": airbrake.Endpoint, "endpoint": airbrake.Endpoint,
}).Info("Failed to send error to Airbrake") }).Info("Failed to send error to Airbrake")
@ -190,11 +190,11 @@ func (hook *AirbrakeHook) Fire(entry *logrus.Entry) error {
} }
// `Levels()` returns a slice of `Levels` the hook is fired for. // `Levels()` returns a slice of `Levels` the hook is fired for.
func (hook *AirbrakeHook) Levels() []logrus.Level { func (hook *AirbrakeHook) Levels() []log.Level {
return []logrus.Level{ return []log.Level{
logrus.ErrorLevel, log.ErrorLevel,
logrus.FatalLevel, log.FatalLevel,
logrus.PanicLevel, log.PanicLevel,
} }
} }
``` ```
@ -236,7 +236,7 @@ that severity or anything above it:
```go ```go
// Will log anything that is info or above (warn, error, fatal, panic). Default. // Will log anything that is info or above (warn, error, fatal, panic). Default.
log.SetLevel(logrus.InfoLevel) log.SetLevel(log.InfoLevel)
``` ```
It may be useful to set `log.Level = logrus.DebugLevel` in a debug or verbose It may be useful to set `log.Level = logrus.DebugLevel` in a debug or verbose