raven-node icon indicating copy to clipboard operation
raven-node copied to clipboard

Ability to see errors in console

Open qrpike opened this issue 8 years ago • 3 comments

I have Raven setup buy my biggest issue is when I'm developing locally I still want to see the messages in my console.

Adding:

Raven.on('logged', function(e){
    console.log('Raven Logged:', e)
})

Only shows me the event ID. How can I also console log the error. Maybe like:

Raven.on('logged', function(e, err){
    console.log('Raven Logged:', e, err)
})

Thanks,

qrpike avatar Jan 25 '17 11:01 qrpike

There's not a particularly good way to do this right now, but #180 is an older PR for roughly the change you're suggesting. The events emitted by Raven are going to need some tweaking with the changes coming for #257, so I'll make sure to keep this in mind.

LewisJEllis avatar Jan 25 '17 17:01 LewisJEllis

@qrpike I'm not sure whether you're referring to uncaughtExceptions but you can use something like:

const ravenEnabled = config.get('sentry.enabled');
const ravenClient = Raven.config(ravenEnabled ? ravenDsn : null).install(function(logged, err) {
  log.error('process is terminating due to uncaught exception', err);
  process.exit(1);
});

However this function only gets called when a ravenDsn is supplied. I have opened https://github.com/getsentry/raven-node/pull/283 to address that particular deficiency with this solution.

esetnik avatar Mar 01 '17 01:03 esetnik

My best workaround so far is to monkey patch raven method:


function override(object, methodName, callback) {
  // eslint-disable-next-line no-param-reassign
  object[methodName] = callback(object[methodName])
}

// Monkey patch 🐒
override(raven, 'captureException', original => {
  return (...args) => {
    // Useful for debugging
    if (process.env.NODE_ENV !== 'test') {
      // eslint-disable-next-line no-console
      console.warn('raven.captureException', ...args)
    }

    original.apply(raven, args)
  }
})

oliviertassinari avatar Oct 25 '17 09:10 oliviertassinari