Skip to content

surikaterna/slf-sentry

Repository files navigation

SLF Sentry Driver

SLF Sentry Driver is a factory for sending SLF logs to Sentry if matching by configured severity level. Exports a factory to create a driver sending all events to the SLF Debug Driver as well.

Purpose

Provide logs of configured severity level to Sentry to assist with investigating issues.

Installation

Install the SLF Sentry Driver as well as the SLF Debug Driver and Debug.js.

npm install slf-sentry slf-debug debug

Usage

Provide the returned value of the SLF Sentry Driver factory when configuring SLF.

Will send all logs to the SLF Debug Driver. If a Sentry URL is provided, it will also send the logs of configured severity level to Sentry. Takes an optional second options argument to configure severity levels.

import debug from 'debug';
import { LoggerFactory } from 'slf';
import createSlfDriver from 'slf-sentry';

debug.enable('viewdb:*');
LoggerFactory.setFactory(createSlfDriver(process.env.SENTRY_URL, {
  level: 'warn',
  environment: 'fat',
  levels: ['warn', 'error']
}));