Giter Club home page Giter Club logo

Comments (5)

rsteckler avatar rsteckler commented on June 7, 2024

winston allows transports to handle uncaught exceptions. The Amazon-SNS and Graylog2 transports are examples that handle this. In node, especially, unhandled exception handling is critical because it's not compiled, strongly typed, and exception handling is "hard" to get right. Alerts on uncaught exceptions are almost necessary even with robust unit test coverage.
If winston-logsene handled uncaught exceptions, I wouldn't need to separate those exceptions out to their own log and tail them with logstash.

from winston-logsene.

otisg avatar otisg commented on June 7, 2024

Big +1. We've been wanting to capture exceptions automatically.

from winston-logsene.

megastef avatar megastef commented on June 7, 2024

This should work now in 1.0.9:

var winston = require('winston')
var Logsene = require('winston-logsene')
var logger = new winston.Logger()
logger.add(Logsene, {
  token: process.env.LOGSENE_TOKEN, 
  handleExceptions: true, 
  exitOnError: false})


BTW: Logstash? ;) Check out https://github.com/sematext/logagent-js

from winston-logsene.

johnpeb avatar johnpeb commented on June 7, 2024

Here's a hack to emulate exitOnError:true

var winston = require('winston');
var winstonLogsene = require('winston-logsene');
var logseneInstance;
var logger = new winston.Logger({
  transports: [
    new winston.transports.Console({
      colorize: true,
      handleExceptions: false,
    }),
    logseneInstance = new winstonLogsene({
      token: process.env.LOGSENE,
      type: process.env.APP || 'api-unkown',
      handleExceptions: false
    })
  ]
});

process.on('uncaughtException', function (err) {
  logger.error(err.stack || err.toString());
  logseneInstance.logger.send(function() {
    process.exit(1);  
  });
});

from winston-logsene.

megastef avatar megastef commented on June 7, 2024

I think this can be closed.

from winston-logsene.

Related Issues (15)

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.