blob: d4ddffca37ffe59a15a670d50a9c285a108c2e32 [file] [log] [blame]
package logrus_test
import (
func Example_hook() {
var log = logrus.New()
log.Formatter = new(logrus.TextFormatter) // default
log.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output
log.Hooks.Add(airbrake.NewHook(123, "xyz", "development"))
log.Out = os.Stdout
"animal": "walrus",
"size": 10,
}).Info("A group of walrus emerges from the ocean")
"omg": true,
"number": 122,
}).Warn("The group's number increased tremendously!")
"omg": true,
"number": 100,
}).Error("The ice breaks!")
// Output:
// level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10
// level=warning msg="The group's number increased tremendously!" number=122 omg=true
// level=error msg="The ice breaks!" number=100 omg=true