1.0.1 • Published 9 years ago

winston-airbrake2 v1.0.1

Weekly downloads
11
License
MIT
Repository
github
Last release
9 years ago

winston-airbrake2

Code Climate Test Coverage

A transport for winston that utilises Airbrake

Usage

npm install winston-airbrake2

Once installed just add the airbrake transport to your winston with your apiKey:

var winston = require('winston');

winston.add(require('winston-airbrake2').Airbrake, {
  apiKey: 'd41d8cd98f00b204e9800998ecf8427e'
});

var message = 'This is my error message';
winston.log('error', message, new Error(message));

Important: to get a meaningful error message logged to your Airbrake project you need to pass an Error object as the meta in winston. Passing an error object will add a stack trace to Airbrake which will allow you to better debug the error:

var message = 'Something went wrong';

winston.log('error', message, new Error(message));
winston.error(message, new Error(message));

Options

All of the options from the node-airbrake module are available.

OptionDefaultDescription
apiKeynull(Required) The apikey that allows you to post to a specific project, this can be found in the project settings.
level'error'(Optional) The level that dictates which logs go to airbrake. by default all error messages will be sent.
host'http://' + os.hostname()(Optional) The information that is displayed within the URL of the Airbrake interface.
envprocess.env.NODE_ENV or 'development'(Optional) The environment will dictate what happens with your message. If your environment is currently one of the 'developmentEnvironments', the error will not be sent to Airbrake.
timeout30000(Optional) The maximum time allowed to send to Airbrake in milliseconds.
developmentEnvironments'development', 'test'(Optional) The environments that will not send errors to Airbrake.
projectRootnull(Optional) Extra information sent to Airbrake
appVersionnull(Optional) Extra information sent to Airbrake
consoleLogErrorfalse(Optional) Toggle the logging of errors when the current environment is in developmentEnvironments

Tests

npm test