Skip to content

gsblue/raygunHook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raygun Hook Build Status Coverage Status GoDoc

A Raygun.io hook for logrus. This package uses raygun http client to notify raygun about errors.

##Usage

import (
	log "github.com/Sirupsen/logrus"
	"github.com/gsblue/raygunHook"
)

func init() {
	h, err := NewHook(&HookConfig{
		APIKey:  "your api key",
		Version: "2.1.10",
		Tags:    []string{"development"},
	})

	if err != nil {
		panic(err)
	}

	log.AddHook(h)
}

func SomeFunctionWhichLogs() {

	err := errors.New("some error")
	r, _ := http.NewRequest("GET", "http://www.google.com", nil)
	log.WithError(err).
		WithField(RequestFieldName, r). //to ensure request is sent to raygun
		WithField(UserFieldName, "john doe"). //to ensure user identifier is sent to raygun
		WithField(CustomDataFieldName, &struct{ OrderNo int }{340}). //to ensure custom data is sent to raygun
		Error()
}

Pull requests are welcome.

About

A Raygun.io hook for logrus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published