logrus_rollbar

package module
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 11 Imported by: 6

README

Rollbar Hook for Logrus v1.4.1

Setup

go get gopkg.in/Scalingo/logrus-rollbar.v1

Example

package main

import (
	"fmt"
	"net/http"
	"math/rand"

	"github.com/sirupsen/logrus"
	"github.com/stvp/rollbar"
	logrusrollbar "gopkg.in/Scalingo/logrus-rollbar.v1"
)


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

	logger := logrus.New()
	logger.Hooks.Add(logrusrollbar.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)
}

Release a New Version

Bump new version number in:

  • CHANGELOG.md
  • README.md

Commit, tag and create a new release:

git add CHANGELOG.md README.md
git commit -m "Bump v1.4.1"
git tag v1.4.1
git push origin master
git push --tags

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SeverityCritical = "critical"
	ErrgoStackSkip   = 15
)

Functions

func New

func New() logrus.Hook

func Wrap

func Wrap(msg string, err error) wrappedError

Types

type RollbarSender

type RollbarSender struct{}

func (RollbarSender) Error

func (s RollbarSender) Error(severity string, err error, fields map[string]interface{})

func (RollbarSender) RequestError

func (s RollbarSender) RequestError(severity string, req *http.Request, err error, fields map[string]interface{})

type Sender

type Sender interface {
	RequestError(string, *http.Request, error, map[string]interface{})
	Error(string, error, map[string]interface{})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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