Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

winston.handleExceptions submits 'false' to papertrail. #40

Closed
chirillc opened this issue Apr 27, 2015 · 14 comments
Closed

winston.handleExceptions submits 'false' to papertrail. #40

chirillc opened this issue Apr 27, 2015 · 14 comments

Comments

@chirillc
Copy link

Hi,
I'm trying to use winston-papertrail to log nodejs/express unhandled exceptions but they show up as "false" in papertrail.
Code snippet:

var winston = require('winston');
winston.handleExceptions(
  new winston.transports.Papertrail({
        host: 'xxx',
        port: xxx,
        hostname: 'xxx',
        inlineMeta: true
    })            
);

Then I throw an exception without catching it, like this:

throw Error('boo');

After spending some time looking into it I could find out that it looks like "level" is being passed as undefined into:

Papertrail.prototype.sendMessage = function (hostname, program, level, message) {
@bitomule
Copy link

I have this issue too, did you find how to fix it?

@MeanwhileMedia
Copy link

I have the same issue.

@kingpalethe
Copy link

I have the same issue. Is there a workaround?

@brocksamson
Copy link

There is a way to work around this, here is my winston-papertrail handleExceptions code block.

var paperTrailLogger = new winston.transports.Papertrail(papertrailConfig);
paperTrailLogger.exceptionsLevel = 'error';
winston.handleExceptions(paperTrailLogger)

The Papertrail constructor function doesn't set exceptionsLevel so the default transport exception handling function ends up sending undefined down to Papertrail.log function.

@whythecode
Copy link

would also be solved by #34

@whythecode
Copy link

+1 though, @brocksamson solves my problem without having to fork the repo:)

var log       = new winston.Logger()
  , transport = new transportClass( transportConfig.config )

transport.exceptionsLevel = 'error'
log.handleExceptions( transport )

// undefined -> no config needed, true -> is already initialized
log.add( transport, undefined, true )

@brocksamson
Copy link

Note that a complete exception handling solution also requires the code changes from #44. The code above will handle uncaught exceptions because the base transport class from winston creates the serialized representation of the object. This will not work however:

try{
    throw new Exception("Guns are for sissies.");
}
catch(ex){
    log.error(ex);
}

See #42 for an explanation of why this fails.

@matteocontrini
Copy link

@brocksamson pull request #44 is pending for that issue

@whythecode
Copy link

@brocksamson - ugh, you're right. I'm actually not even getting the "false" messages now. Hopefully this will be fixed soon..........

@jareware
Copy link

jareware commented Mar 2, 2016

Also seeing this, any chance of updating this transport?

@troy
Copy link
Contributor

troy commented Mar 2, 2016

@jareware (and anyone else who wants this): check out and subscribe to #34

@jareware
Copy link

jareware commented Mar 2, 2016

Good to know, thanks!

@troy
Copy link
Contributor

troy commented Apr 29, 2016

If you're reading this message, we'd love if you can pull the current master of winston-papertrail and run it. We'll wait at least 2 weeks to see whether any issues come up from wider use of this and one other change. If you encounter problems with master which don't occur in the current release, please open a new GitHub Issue with the transcript and reference #34.

@troy troy closed this as completed Apr 29, 2016
@troy
Copy link
Contributor

troy commented Aug 24, 2016

This is live on NPM in version 1.0.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants