joonathan / logrus-rollbar

Rollbar Hook for logrus. Use errgo to create a complete stack of the error

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rollbar hook for Logrus

Setup

go get github.com/Appsdeck/logrus-rollbar

Example

package main

import (
	"fmt"
	"net/http"
	"math/rand"
	
	"github.com/Sirupsen/logrus"
	rollbar "github.com/AlekSi/rollbar-go"
	logrus_rollbar "github.com/Appsdeck/logrus-rollbar"
)


func main() {
	rollbar.ApiKey = "123456ABCD"
	rollbar.Environment = "testing"

	logger := logrus.New()
	logger.Hooks.Add(logrus_rollbar.Hook{})

	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		err := fmt.Errorf("something wrong happened in the database")

		logger.WithFields(
			logrus.Fields{"req": r, "error": err, "extra-data", rand.Int()},
		).Error("Something is really wrong")
	})

	http.ListenAndServe(":31313", nil)
}

About

Rollbar Hook for logrus. Use errgo to create a complete stack of the error


Languages

Language:Go 100.0%