UNPKG

@roarr/sentry

Version:

Sentry integration that adds Roarr logs to Sentry breadcrumbs.

44 lines (43 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createRoarrSentryIntegration = void 0; const roarr_1 = require("roarr"); const getSeverity = (logLevelName) => { switch (logLevelName) { case 'trace': case 'debug': return 'debug'; case 'info': return 'info'; case 'warn': return 'warning'; case 'error': return 'error'; default: return 'error'; } }; const createRoarrSentryIntegration = ({ addBreadcrumb, }) => { return new class CaptureRoarr { constructor() { this.name = 'CaptureRoarr'; this.setupOnce = () => { const originalWrite = roarr_1.ROARR.write; roarr_1.ROARR.write = (jsonMessage) => { const message = JSON.parse(jsonMessage); addBreadcrumb({ category: message.context.namespace, data: { context: message.context, }, level: getSeverity((0, roarr_1.getLogLevelName)(message.context.logLevel)), message: message.message, type: 'default', }); originalWrite(jsonMessage); }; }; } }(); }; exports.createRoarrSentryIntegration = createRoarrSentryIntegration;