Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Ability to see errors in console #259

Open
qrpike opened this issue Jan 25, 2017 · 3 comments
Open

Ability to see errors in console #259

qrpike opened this issue Jan 25, 2017 · 3 comments

Comments

@qrpike
Copy link

qrpike commented Jan 25, 2017

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,

@LewisJEllis
Copy link
Contributor

LewisJEllis commented Jan 25, 2017

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.

@esetnik
Copy link

esetnik commented Mar 1, 2017

@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 #283 to address that particular deficiency with this solution.

@oliviertassinari
Copy link
Contributor

oliviertassinari commented Oct 25, 2017

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)
  }
})

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants