Home

Awesome

Airbrake Hook for Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:" /> Build Status godoc reference

Use this hook to send your errors to Airbrake. This hook is using the official airbrake go package, and will hit the api V4. The hook is synchronous and will send the error for log.Error, log.Fatal and log.Panic levels.

All logrus fields will be sent as context fields on Airbrake.

Usage

The hook must be configured with:

import (
    "log/syslog"
    "github.com/sirupsen/logrus"
    "gopkg.in/gemnasium/logrus-airbrake-hook.v4" // the package is named "aibrake"
    )

func main() {
    log := logrus.New()
    log.AddHook(airbrake.NewHook(123, "xyz", "production"))
    log.Error("some logging message")
}

Note that if environment == "development", the hook will not send anything to airbrake.

Reporting http request failure

import (
    "log/syslog"
    "github.com/sirupsen/logrus"
    "gopkg.in/gemnasium/logrus-airbrake-hook.v4" // the package is named "aibrake"
    )

func main() {
    log := logrus.New()
    log.AddHook(airbrake.NewHook(123, "xyz", "production"))
req, err := http.NewRequest("GET", "http://example.com", nil)
    log.WithField("request", req).Error("some logging message")
}

Notes: