Plugin for the @jitesoft/yolog
logger to post logs and errors to Sentry.
Install with your favorite package manager!
npm i @jitesoft/yolog-sentry-plugin --save
yarn add @jitesoft/yolog-sentry-plugin
The plugin uses the @sentry/minimal
package to make sure that it works on both browser and node alike.
You have to install the sentry plugin required for your current environment (@sentry/node
, @sentry/browser
)
and set it up as you wish.
When that is done, the yolog-sentry-plugin
will be able to send its logs and errors to sentry.
import logger from '@jitesoft/yolog';
import SentryPlugin from '@jitesoft/yolog-sentry-plugin';
import * as Sentry from '@sentry/node (or browser)';
Sentry.init({
dsn: 'some-dsn-to-connect-to-sentry'
});
logger.addPlugin(new SentryPlugin());
logger.alert('Oh no!');
It is possible to add tags
, extras
and user
to the data sent to sentry, the way to do this is to
add a provider
to the plugin statically.
The providers are callback functions which will be used to fetch the data required. The tags
and extras
providers
should return objects with standard key-value pairs while the userProvider
should return a user object. For more documentation on what values are expected and/or
what will happen to them, refer to the Sentry documentation.
Currently, the fingerprint
is the full message that is passed through the logger.