logrusbadger

package module
v0.0.0-...-a81ee97 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2018 License: MIT Imports: 3 Imported by: 0

README

logrusbadger GoDoc

logrusbadger is a logrus-compatible hook that uses the official Honeybadger go library to notify Honeybadger.

Any fields included with the log message will be added to the context of the honeybadger notification, and the main message of the log will be used as it's type. Any error added using logrus's WithError function will be set as the exception's type. This encourages you to use generic error messages like retrieving current user as your message, while added specific details as additional fields.

Usage

Just register the hook with logrus. All configuration (API keys, timeouts, etc) should happen via Honeybadger's official libraries.

log.AddHook(logrusbadger.NewHook())
License

This library is MIT licensed. See the LICENSE file in this repository for details.

Documentation

Overview

Package logrusbadger is a logrus-compatible hook that uses the official Honeybadger go library to notify Honeybadger. Any fields included with the log message will be added to the context of the honeybadger notification, and the main message of the log will be used as it's type. Any error added using logrus's WithError function will be set as the exception's type. This encourages you to use generic error messages like "retrieving current user" as your message, while added specific details as additional fields.

Control over timeouts, API keys, and other options should be done through the Honeybadger's library. This uses its Notify package-level function, so any changes to that DefaultClient will take effect for this library as well.

logrusbadger is influenced greatly by github.com/agonzalezro/logrus_honeybadger.

Index

Constants

This section is empty.

Variables

DefaultLevels control the levels that will notify Honeybadger.

Functions

This section is empty.

Types

type Hook

type Hook struct {
	// contains filtered or unexported fields
}

Hook is a logrus.Hook implementor that notifies Honeybadger.

func NewHook

func NewHook() *Hook

NewHook instantiates a Hook configured to use honeybadger.DefaultClient.

func (*Hook) Fire

func (h *Hook) Fire(entry *logrus.Entry) error

Fire notifies Honeybadger with the passed-in entry. This will be called automatically by logrus for messages of the appropriate level.

func (*Hook) Levels

func (h *Hook) Levels() []logrus.Level

Levels tells logrus what message level we care about, and can be tweaked via the DefaultLevels pacakge-level var.

Jump to

Keyboard shortcuts

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