开发者社区> 镜像站> NPM> book-raven
book-raven
raven middleware for the book logging framework
Last updated 3 years ago by defunctzombie .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install book-raven 
SYNC missed versions from official npm registry.

book-raven

raven middleware for the book logging framework

use

var log = require('book').default();

// add the middleware to your logger
log.use(require('book-raven')('your sentry DSN here'));

log.warn('hello world');
log.info('hello world was logged');

handle errors from sentry

Sometimes the messages cannot be sent to sentry. In this case the on_error function will be called with the error. If no on_error function is specified, the error will simply be thrown and any uncaughtException handlers you have installed will catch it (or your app will crash).

It is recommended to install some sort of on_error handler.

log.use(require('book-raven')('DSN', {
    on_error: function(err) {
        console.error(err);
    }
});

configure levels to send

By default, only PANIC, ERROR, and WARN levels are sent to sentry. If you wish to By default, all log entries are sent. If you wish to limit logging to specific levels use the ignore_levels option.

Below is an example of ignoring all levels above (less critical) than WARN. So PANIC, ERROR, and WARN will be sent to sentry, but INFO, DEBUG, and TRACE will not.

log.use(require('book-raven')('DSN', {
    ignore_levels: log.WARN
    on_error: function(err) {
        console.error(err);
    }
});

uncaughtException

If you use process uncaughtException to handle the error and wish to exit. Make sure to exit after a short timeout. This will give the raven logger a chance to send the http request.

process.on('uncaughtException', function(err) {
    log.panic(err);
    setTimeout(process.exit.bind(process, 1), 1500);
})

install

npm install book
npm install book-raven

Current Tags

  • 1.2.2                                ...           latest (3 years ago)

10 Versions

  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           8 years ago
  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
  • 0.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 4
Last Month 7
Dependencies (2)
Dev Dependencies (3)
Dependents (2)