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

Uncaught Exceptions Dont Reach Stdout #6

Closed
pixelshaded opened this issue Jun 29, 2012 · 2 comments
Closed

Uncaught Exceptions Dont Reach Stdout #6

pixelshaded opened this issue Jun 29, 2012 · 2 comments

Comments

@pixelshaded
Copy link

So in one of my environment files

var fs = require('fs');

var stream = fs.createWriteStream("./log/stream.log", {
    flags: "a",
    encoding: "utf8",
    mode: 0666
});

app.tracerSettings.transport = function(data) {
    stream.write(app.tim(app.tracerSettings.format, data)+"\n\n");
}

app.logger = require('tracer').colorConsole(app.tracerSettings);

process.on('uncaughtException', function(error){
   app.logger.error(error.stack);
   stream.end();
});

stream.on('close', function(){
    stream.destroy();
    process.exit(1);
});

When I get an uncaught exception, I'm trying to log the stack, end the write stream for my transport, and on close event, destroy the stream and process.exit (1) (so forever can hear this event and restart the server).

The log file is written to, but my terminal is not getting the stack. Any ideas?

@pixelshaded
Copy link
Author

actually, I see now that the transport example is using console log with the data.output. I understand now.

@baryon
Copy link
Owner

baryon commented Jun 30, 2012

if you want get stack, see example
https://github.com/baryon/tracer/blob/master/example/format2.js

@baryon baryon closed this as completed Jul 29, 2012
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

2 participants