Coder Social home page Coder Social logo

rollrus's Introduction

CircleCIย GoDoc

What

Rollrus is what happens when Logrus meets Rollbar.

Install the hook into a Logrus logger to report logged messages to Rollbar. By default, only messages with the Error, Fatal, or Panic level are reported.

Panic and Fatal errors are reported synchronously to help ensure that logs are delivered before the process exits. All other messages are delivered in the background, and may be dropped if the queue is full.

If the error includes a StackTrace, that StackTrace is reported to rollbar.

Usage

Examples available in the tests or on GoDoc.

rollrus's People

Contributors

alex-pk avatar apg avatar bernerdschaefer avatar cyx avatar ferhatelmas avatar fgblomqvist avatar gsempe avatar joshwlewis avatar jsncmgs1 avatar mback2k avatar owenthereal avatar pkopac avatar voidlock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

rollrus's Issues

Ignore well-known error fields when reporting custom fields

I think it's better to ignore all of the well-known error fields when reporting the custom fields, since they are/should be already taken care of by rollrus in some other fashion (e.g. by putting the cause error in the title, like rollrus already does).

Or, at the very least, there needs to be some detection whether a custom field is an error, and if it is, just send the message (an error with a stack trace from github.com/pkg/errors currently gets sent with the whole stack trace, which is unnecessary since the stack trace is already taken care of separately).

This package clobbers your existing formatter

Hey. I just found this today and it's perfect for what I need, except:

log.SetFormatter(&log.TextFormatter{DisableTimestamp: true})

Why is this in here exactly? I'm using log.JsonFormatter so I can easily parse my logs on-disk (which contain all sorts of other stuff). I was surprised when a hook actually overwrote this!

License

Could you add a license for rollrus?

extractError() will discard stack if root cause doesn't have a stack trace attached

Since extractError() only looks at the root cause and discards other errors in the error stack (https://github.com/heroku/rollrus/blob/master/rollrus.go#L270-L275), if there are multiple wrapped errors and the root cause does not have a stacktrace, it will discard the stacktraces from the other errors. I propose that it uses the deepest stack it can find:

func getDeepestStackTrace(err error) errors.StackTrace {
	type errorCauser interface {
		Cause() error
	}
	type stackTracer interface {
		StackTrace() errors.StackTrace
	}

	var deepestStackTrace errors.StackTrace
	for {
		if tracer, ok := err.(stackTracer); ok {
			deepestStackTrace = tracer.StackTrace()
		}

		if causer, ok := err.(errorCauser); ok {
			err = causer.Cause()
		} else {
			break
		}
	}
	return deepestStackTrace
}

Error message is discarded when embedding an error

Hi,

whenever WithError is used to log a message, the cause is taken from the embedded error and the logged message gets completely lost.

Example:

package main

import (
	"github.com/heroku/rollrus"
	log "github.com/sirupsen/logrus"
	"errors"
)

func main() {
	log.SetLevel(log.ErrorLevel)
	rollbarHook := rollrus.NewHook("bc", "test")
	log.AddHook(rollbarHook)

	log.WithError(errors.New("[Testing] inner message")).Error("[Testing] outer message")
}

This is what appears on rollbar:

 Traceback (most recent call last):
File "github.com/heroku/rollrus/rollrus.go" line 191 in rollrus.(*Hook).report
File "github.com/heroku/rollrus/rollrus.go" line 170 in rollrus.(*Hook).Fire
File "github.com/sirupsen/logrus/hooks.go" line 28 in logrus.LevelHooks.Fire
File "github.com/sirupsen/logrus/entry.go" line 98 in logrus.Entry.log
File "github.com/sirupsen/logrus/entry.go" line 159 in logrus.(*Entry).Error
File "rollrustest.go" line 15 in main.main

{699508d8}: [Testing] inner message

The "outer message" does not appear anywhere.

I traced down the problem to extractError, which takes the cause from the err field if it is present.

In my opinion, if there is an entry.Message, that should be used as cause, and the err field's cause should be logged in a separate field.

I can prepare a PR if needed.

Thanks!

Don't require development dependencies

If deps are vendored for various reasons (i.e. cache), a lot of unnecessary code (golang-ci, go-critic) are pulled and put into git.

Suggested solution(s):

  • install under a temporary folder and use the binary
  • pull the binary directly

Migrate to go modules?

If this is of interest (which I believe it should be), I can submit a PR since I forked rollrus today and made the (tiny) changes to adopt go modules.

New Trace log level 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.

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.