@synapsestudios/winston-sentry
v2.1.0
Published
Winston transport for sentry
Downloads
9,475
Maintainers
Keywords
Readme
winston-sentry
A simple winston transport that logs your errors to sentry.
This transport is for winston 3.x and uses the new @sentry/node
SDK instead of Raven.
Installation
npm install --save @synapsestudios/winston-sentry
Usage
Follow the steps in sentry's docs to set up your node sdk. The transport doesn't set up the sentry SDK for you in case you want to make any of your own sentry calls outside of the context of winston.
Initialize the transport and tell winston about it like this:
const winston = require('winston');
const SentryTransport = require('@synapsestudios/winston-sentry');
const Sentry = require('@sentry/node');
Sentry.init({
/* sentry init values */
});
module.exports = new winston.Logger({
transports: [
/* ... your other transports */
new SentryTransport({ Sentry }),
]
});
Logging behavior
Whenever an error with level fatal
or error
are logged with your winston logger that error will also be logged to sentry.