ihrwein / gobrake

Airbrake notifier for Golang

Home Page:http://godoc.org/gopkg.in/airbrake/gobrake.v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Airbrake Golang Notifier Build Status

Example

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)
}

Ignoring notices

airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice {
	if notice.Context["environment"] == "development" {
		// Ignore notices in development environment.
		return nil
	}
	return notice
})

Setting severity

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)

Logging

You can use glog fork to send your logs to Airbrake.

About

Airbrake notifier for Golang

http://godoc.org/gopkg.in/airbrake/gobrake.v2

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 99.6%Language:Makefile 0.4%