Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

winston-sentry-javascript-node

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-sentry-javascript-node

Sentry transport for the winson logger that using official Sentry SDK for javascript instead of the old Raven.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

winston-sentry-javascript-node

winston

Sentry transport for the winson logger 3+ and uses the @sentry/node SDK instead of the old Raven.

This package is written in Typescript with the well typing and code quality.

Installation

npm install winston-sentry-javascript-node --save

Usage

import { SentryTransport } from 'winston-sentry-javascript-node';

const logger = winston.createLogger({
  transports: [
    new SentryTransport({
      dsn: 'MY_SENTRY_DSN',
    }),
  ],
});

logger.error('Plain text error.');
logger.error(new Error('Something went wrong.'));

Extra / Tags / User Example

Set user information, as well as tags and further extras.

logger.error('Plain text error.', {
  extra: {
    foo: 'bar',
  },
  tags: {
    foo: 'bar'
  },
  user: {
    ip: '127.0.0.1',
    username: 'user1'
  }
});

Handle Exception

Catch and send uncaughtException to the Sentry.

const logger = winston.createLogger({
  transports: [
    new SentryTransport({
      dsn: 'MY_SENTRY_DSN',
      handleExceptions: true,
    }),
  ],
});

// or

const logger = winston.createLogger({
  exceptionHandlers: [
    new SentryTransport({
      dsn: 'MY_SENTRY_DSN',
    }),
  ]
});

Default Extra for Error Object

By default, if you provide an Error Object to logger, this package will set the following extra:

{
  stack: err.stack,
  message: err.message
}

© Ben Hu (benjamin658), 2019-NOW

Released under the MIT License

Keywords

FAQs

Package last updated on 24 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc