Code Monkey home page Code Monkey logo

logrus-bugsnag's Introduction

logrus-bugsnag

Build Status

logrus-bugsnag is a hook that allows Logrus to interface with Bugsnag.

Usage

import (
  log "github.com/sirupsen/logrus"
  "github.com/Shopify/logrus-bugsnag"
  bugsnag "github.com/bugsnag/bugsnag-go"
)

func init() {
  bugsnag.Configure(bugsnag.Configuration{
    APIKey: apiKey,
  })
  hook, err := logrus_bugsnag.NewBugsnagHook()
  logrus.StandardLogger().Hooks.Add(hook)
}

logrus-bugsnag's People

Contributors

burke avatar csfrancis avatar jules2689 avatar lavoiesl avatar n1koo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

logrus-bugsnag's Issues

Problem with the static value of skipStackFrames

Depending on how you call the logger you receive different number of entries related to logrus in the stacktrace,

  • log.WithFields(...).Error gives four entries that is related to logrus - all covered and removed with the hardcoded value of skipStackFrames = 4.
  • log.Error gives five - one extra
  • log.Errorf gives six - two extra

Below is by manipulating bugsnag_test.go

log.Errorf

[]logrus_bugsnag.stackFrame{
logrus_bugsnag.stackFrame{Method:"(*Entry).Errorf", File:"github.com/Sirupsen/logrus/entry.go", LineNumber:193},
logrus_bugsnag.stackFrame{Method:"(*Logger).Errorf", File:"github.com/Sirupsen/logrus/logger.go", LineNumber:103}, 
logrus_bugsnag.stackFrame{Method:"TestNoticeReceived", File:"github.com/Shopify/logrus-bugsnag/bugsnag_test.go", LineNumber:70}, 
logrus_bugsnag.stackFrame{Method:"tRunner", File:"testing/testing.go", LineNumber:473},
logrus_bugsnag.stackFrame{Method:"goexit", File:"runtime/asm_amd64.s", LineNumber:1998}}

log.Error

[]logrus_bugsnag.stackFrame{
logrus_bugsnag.stackFrame{Method:"(*Logger).Error", File:"github.com/Sirupsen/logrus/logger.go", LineNumber:150}, 
logrus_bugsnag.stackFrame{Method:"TestNoticeReceived", File:"github.com/Shopify/logrus-bugsnag/bugsnag_test.go", LineNumber:70}, 
logrus_bugsnag.stackFrame{Method:"tRunner", File:"testing/testing.go", LineNumber:473}, 
logrus_bugsnag.stackFrame{Method:"goexit", File:"runtime/asm_amd64.s", LineNumber:1998}}

log.WithFields(...).Error

[]logrus_bugsnag.stackFrame{
logrus_bugsnag.stackFrame{Method:"TestNoticeReceived", File:"github.com/Shopify/logrus-bugsnag/bugsnag_test.go", LineNumber:77}, 
logrus_bugsnag.stackFrame{Method:"tRunner", File:"testing/testing.go", LineNumber:473}, 
logrus_bugsnag.stackFrame{Method:"goexit", File:"runtime/asm_amd64.s", LineNumber:1998}}

Any idea on how to solve this?

logrus: bugsnag_test.go:107: Unexpected method on top of call stack

$ go test -vet=off -v -p 8 github.com/Shopify/logrus-bugsnag/
=== RUN   TestNoticeReceived
2018/05/16 17:40:11 notifying bugsnag: foo
--- FAIL: TestNoticeReceived (0.00s)
	bugsnag_test.go:107: Unexpected method on top of call stack: got "(*Entry).Error", expected "TestNoticeReceived"
FAIL
=== RUN   TestNoticeReceived
time="2018-05-16T17:40:11+07:00" level=error msg="Bugsnag will not see this string" animal=walrus error=foo omg=true size=9009
FAIL	github.com/Shopify/logrus-bugsnag	0.005s

New Trace leve in logrus

Hello, I'm just opening this issue to let you know, the next release of logrus (v1.2.0) will add a new trace level named Trace below Debug.
Here is the PR for reference sirupsen/logrus#844
You may want to take into account this new level.

Go 1.10: bugsnag_test.go:91: Error call has possible formatting directive %d

6dbc35f does not pass unit tests with Go 1.10:

+ GOPATH=/builddir/build/BUILD/logrus-bugsnag-6dbc35f2c30d1e37549f9673dd07912452ab28a5/_build:/usr/share/gocode
+ go test -buildmode pie -compiler gc -ldflags '-extldflags '\''-Wl,-z,relro  '\'''
# github.com/Shopify/logrus-bugsnag
./bugsnag_test.go:91: Error call has possible formatting directive %d
FAIL    github.com/Shopify/logrus-bugsnag [build failed]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.