-
Notifications
You must be signed in to change notification settings - Fork 24
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
exitOnError / .handleExceptions() #4
Comments
+1 |
Hi, i have tried this code: const winston = require('winston');
const winstonLogzIO = require('winston-logzio');
const loggerOptions = {
token: 'ekByhvPZHSsGvYOGfAkrEpHIiFvybwzH',
type: 'bla', // OPTIONAL (If none is set, it will be 'nodejs')
debug: true,
};
const logzIOTransport = new (winstonLogzIO)(loggerOptions);
const logger = new (winston.Logger)({
transports: [
logzIOTransport
],
exceptionHandlers: [
logzIOTransport
],
exitOnError: true // set this to true
});
process.on('uncaughtException', function (err) {
console.error("UncaughtException processing: %s", err);
logger.error("UncaughtException processing: %s", err);
logzIOTransport.flush(function (callback) {
process.exit(1);
});
});
winston.log('info', { 'wwp': 'asd' });
setTimeout(() => procces.exit(), 3000);
throw new Error('test error'); and logs were sent successfuly
can you elaborate, or share a code snippet with the issue? |
Process.on statement wouldn't be necessary if handleExceptions worked properly. In other words, that is the "patchy" way of handling exceptions, specially when having to flush the transport. |
indeed, we would love a PR for that to be submitted 👍 |
Hey,
I've tried adding the exitOnError and handleExceptions to my logger but they don't work.
I'm using different containers and I want one container to exitOnError and handleExcepetions because critical errors are not being sent (because the app shutdown too early..)
thanks :)
The text was updated successfully, but these errors were encountered: