logrus/hooks/sentry
Roberto Bampi 383ab1fb69 added delivery timeout 2014-11-06 21:17:29 +01:00
..
README.md various fixes 2014-11-06 10:07:41 +01:00
sentry.go added delivery timeout 2014-11-06 21:17:29 +01:00
sentry_test.go various fixes 2014-11-06 10:07:41 +01:00

README.md

Sentry Hook for Logrus :walrus:

Sentry provides both self-hosted and hosted solutions for exception tracking. Both client and server are open source.

Usage

Every sentry application defined on the server gets a different DSN. In the example below replace YOUR_DSN with the one created for your application.

import (
  "github.com/Sirupsen/logrus"
  "github.com/Sirupsen/logrus/hooks/sentry"
)

func main() {
  log       := logrus.New()
  hook, err := logrus_sentry.NewSentryHook(YOUR_DSN, []logrus.Level{
    logrus.PanicLevel,
    logrus.FatalLevel,
    logrus.ErrorLevel,
  })

  if err == nil {
    log.Hooks.Add(hook)
  }
}

Special fields

Some logrus fields have a special meaning in this hook, these are server_name and logger. When logs are sent to sentry these fields are treated differently.

  • server_name (also known as hostname) is the name of the server which is logging the event (hostname.example.com)
  • logger is the part of the application which is logging the event. In go this usually means setting it to the name of the package.