evalphobia / logrus_sentry

sentry hook for logrus
MIT License
194 stars 78 forks source link

Use release and environment from raven client #84

Open montanaflynn opened 5 years ago

montanaflynn commented 5 years ago

I'm using the hook with a raven client like so:

ravenClient, err := raven.New(sentryDSN)
if err != nil {
    log.Fatal(err)
}

ravenClient.SetRelease(release)
ravenClient.SetEnvironment(environment)

// set up error logs and stacktrace to send to sentry
hook, err := logrus_sentry.NewAsyncWithClientSentryHook(ravenClient, []logrus.Level{
    logrus.PanicLevel,
    logrus.FatalLevel,
    logrus.ErrorLevel,
})
logger.Hooks.Add(hook)

But the hook isn't sending the correct release or environment. I think I have to set them manually on the hook like this:

hook.SetRelease(release)
hook.SetEnvironment(environment)

It would be nice for this package to use the already configured release and environment from the raven client used to create the hook.

thomas-lee commented 5 years ago

I have tried, it now works without further setting.