Coder Social home page Coder Social logo

winston-sentry-log's Introduction

winston-sentry-log

Sentry transport for the winston v3 logger using @sentry/node.

Index

Install

yarn add winston winston-sentry-log

Usage

You can configure winston-sentry-log in two different ways.

With new winston.Logger:

import winston from 'winston';
import Sentry from 'winston-sentry-log';

const options = {
  dsn: "https://******@sentry.io/12345",
  level: "info"
};

const logger = new winston.createLogger({
  transports: [new Sentry(options)]
});

Or with winston's add method:

import winston from 'winston';
import Sentry from 'winston-sentry-log';

const logger = new winston.createLogger();

logger.add(Sentry, options);

See Options below for custom configuration.

Options (options)

Per options variable above, here are the default options provided:

Default Sentry options:

  • dsn (String) - your Sentry DSN or Data Source Name (defaults to process.env.SENTRY_DSN)

Transport related options:

  • name (String) - transport's name (defaults to winston-sentry-log)
  • silent (Boolean) - suppress logging (defaults to false)
  • level (String) - transport's level of messages to log (defaults to info)
  • levelsMap (Object) - log level mapping to Sentry (see Log Level Mapping below)

Default Sentry Options (options.config)

  • logger (String) - defaults to winston-sentry-log
  • server_name (String) - defaults to process.env.SENTRY_NAME or os.hostname()
  • release (String) - defaults to process.env.SENTRY_RELEASE
  • environment (String) - defaults to process.env.SENTRY_ENVIRONMENT)
  • modules (Object) - defaults to package.json dependencies
  • extra (Object) - no default value
  • fingerprint (Array) - no default value

For a full list of Sentry options, please visit https://docs.sentry.io/clients/node/config/.

Log Level Mapping

Winston logging levels are mapped by default to Sentry's acceptable levels.

These defaults are set as options.levelsMap and are:

{
  silly: 'debug',
  verbose: 'debug',
  info: 'info',
  debug: 'debug',
  warn: 'warning',
  error: 'error'
}

You can customize how log levels are mapped using the levelsMap option:

new Sentry({
  levelsMap: {
    verbose: "info"
  }
});

If no log level mapping was found for the given level passed, then it will not log anything.

License

MIT License

winston-sentry-log's People

Contributors

bushev avatar franciscofsales avatar nenadalm avatar pflugs30 avatar riker09 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.