From 330e34061ed41f46e4d5e4f729026fd0798836e9 Mon Sep 17 00:00:00 2001 From: Simon Eskildsen Date: Sat, 26 Jul 2014 22:51:23 -0400 Subject: [PATCH] readme: fix examples --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7643a04..a171763 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ import ( ) func main() { - log.WithFields(logrus.Fields{ - "animal": "walrus" + log.WithFields(log.Fields{ + "animal": "walrus", }).Info("A walrus appears") } ``` @@ -91,17 +91,17 @@ func init() { } func main() { - log.WithFields(logrus.Fields{ + log.WithFields(log.Fields{ "animal": "walrus", "size": 10, }).Info("A group of walrus emerges from the ocean") - log.WithFields(logrus.Fields{ + log.WithFields(log.Fields{ "omg": true, "number": 122, }).Warn("The group's number increased tremendously!") - log.WithFields(logrus.Fields{ + log.WithFields(log.Fields{ "omg": true, "number": 100, }).Fatal("The ice breaks!") @@ -124,9 +124,9 @@ var log = logrus.New() func main() { // The API for setting attributes is a little different than the package level // exported logger. See Godoc. - log.Out = os.Sderr + log.Out = os.Stderr - log.WithFields(logrus.Fields{ + log.WithFields(log.Fields{ "animal": "walrus", "size": 10, }).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: ```go -log.WithFields(logrus.Fields{ +log.WithFields(log.Fields{ "event": event, "topic": topic, "key": key, @@ -180,7 +180,7 @@ type AirbrakeHook struct{} func (hook *AirbrakeHook) Fire(entry *logrus.Entry) error { err := airbrake.Notify(entry.Data["error"].(error)) if err != nil { - log.WithFields(logrus.Fields{ + log.WithFields(log.Fields{ "source": "airbrake", "endpoint": airbrake.Endpoint, }).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. -func (hook *AirbrakeHook) Levels() []logrus.Level { - return []logrus.Level{ - logrus.ErrorLevel, - logrus.FatalLevel, - logrus.PanicLevel, +func (hook *AirbrakeHook) Levels() []log.Level { + return []log.Level{ + log.ErrorLevel, + log.FatalLevel, + log.PanicLevel, } } ``` @@ -236,7 +236,7 @@ that severity or anything above it: ```go // 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