winston-rollbar-transport
A winston logger transport for Rollbar.
Install
npm install --save winston-rollbar-transport winston
Requires Node v6+
Usage
const logger = transports: // required rollbarAccessToken: processenvROLLBAR_ACCESS_TOKEN rollbarConfig: // optional // see https://github.com/rollbar/node_rollbar#configuration-reference level: 'info' // log level. defaults to 'info' // regular logginglogger // logging with custom metadatalogger // logging with request datalogger // logging an error// Important: the second parameter is not optional (see below)logger
Error handling
Since Winston log messages are converted to strings,
winston-rollbar-transport
will only see a string if logger.error(new Error())
is called and can't therefore report the exception propoerly
to Rollbar with rollbar.handleErrorWithPayloadData
.
Therefore, to correctly report exceptions, use the err
key on the meta
field in addition to the message. For example:
logger
See ./test directory for usage examples.