Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonny64/winston-sentry-dia
https://github.com/jonny64/winston-sentry-dia
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jonny64/winston-sentry-dia
- Owner: jonny64
- Created: 2021-12-18T18:19:28.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-28T10:32:45.000Z (almost 3 years ago)
- Last Synced: 2024-10-28T13:28:42.369Z (about 2 months ago)
- Language: JavaScript
- Size: 107 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![build](https://github.com/jonny64/winston-sentry-dia/actions/workflows/build.yml/badge.svg)](https://github.com/jonny64/winston-sentry-dia/actions/workflows/build.yml)
# winston-sentry-dia
A simple winston transport that logs [dia.js](https://github.com/do-/dia.js/) errors to sentry.
This transport is for winston 3.x and uses `@sentry/node` SDK.
## Installation
```
npm install --save winston-sentry-dia @sentry/node winston
```## Usage
Follow the steps in [sentry's docs](https://docs.sentry.io/error-reporting/quickstart/?platform=node) 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 Sentry = require('@sentry/node')
const SentryTransportDia = require ('winston-sentry-dia')init_logging () {
this.logging_container = new winston.Container ()
Sentry.init (this.sentry)
for (let category of ['app', 'db', 'http', 'queue', 'f_s']) this.logging_container.add (category, {
format: new Dia.Logger ({category}),
transports: [
new winston.transports.Console (),
new SentryTransportDia ({ Sentry })
]})
}
```
## Logging behavior
Whenever an error with level `error` are logged with your winston logger that error will also be logged to sentry.
All previous events with lower level will are cached as [breadcrumbs](https://docs.sentry.io/platforms/node/enriching-events/breadcrumbs/)