package main
import (
"errors"
"github.com/airbrake/gobrake"
)
var airbrake = gobrake.NewNotifier(1234567, "FIXME")
func init() {
airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice {
notice.Context["environment"] = "production"
return notice
})
}
func main() {
defer airbrake.Close()
defer airbrake.NotifyOnPanic()
airbrake.Notify(errors.New("operation failed"), nil)
}
airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice {
if notice.Context["environment"] == "development" {
// Ignore notices in development environment.
return nil
}
return notice
})
Severity allows
categorizing how severe an error is. By default, it's set to error
. To
redefine severity, simply overwrite context/severity
of a notice object. For
example:
notice := airbrake.Notice("operation failed", nil, 3)
notice.Context["severity"] = "critical"
airbrake.Notify(notice, nil)
You can use glog fork to send your logs to Airbrake.