gemnasium / logrus-airbrake-legacy-hook

Hook for Logrus to send errors to an exception tracking service compatible with the Airbrake API. Uses https://github.com/tobi/airbrake-go behind the scenes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Airbrake "legacy" Hook for Logrus :walrus: Build Status godoc reference

Use this hook to send your errors to Airbrake. This hook is using airbrake-go behind the scenes. The hook is a blocking call for log.Error, log.Fatal and log.Panic.

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

Usage

The hook must be configured with:

  • The URL of the api (ex: your errbit host url)
  • An API key ID
  • The name of the current environment ("development", "staging", "production", ...)
import (
    "log/syslog"
    "github.com/sirupsen/logrus"
    "gopkg.in/gemnasium/logrus-airbrake-legacy-hook.v1" // the package is named "aibrake"
    )

func main() {
    log := logrus.New()

    // Use the Airbrake hook to report errors that have Error severity or above to
    // an exception tracker. You can create custom hooks, see the Hooks section.
    log.AddHook(airbrake.NewHook("https://example.com", "xyz", "development"))
    log.Error("some logging message") // The error is sent to airbrake in background
}

About

Hook for Logrus to send errors to an exception tracking service compatible with the Airbrake API. Uses https://github.com/tobi/airbrake-go behind the scenes.

License:MIT License


Languages

Language:Go 100.0%