airbrake

package module
v2.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2017 License: MIT Imports: 6 Imported by: 202

README

Airbrake Hook for Logrus  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 V3. 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:

  • A project ID (found in your your Airbrake project settings)
  • An API key ID (found in your your Airbrake project settings)
  • The name of the current environment ("development", "staging", "production", ...)
import (
    "log/syslog"
    "github.com/sirupsen/logrus"
    "gopkg.in/gemnasium/logrus-airbrake-hook.v2" // 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.v2" // 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:

  • the req will be removed from the log entry
  • the name of the field doesn't matter, since it's not logged
  • if more than one request is sent, only the first will be taken into account (and the others will be logged as strings)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHook

func NewHook(projectID int64, apiKey, env string) *airbrakeHook

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL