-
Notifications
You must be signed in to change notification settings - Fork 893
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
Pino 5.8.1 fails to flush log on process exit #542
Comments
I am running into this as well. I added If I put a 100 ms delay before the |
@brandondoran I found that using |
What you can do is: const pino = require('.');
const dest = pino.destination(1);
const logger = pino(dest);
try {
logger.info('start', pino.version);
throw new Error('oops');
} catch (e) {
logger.error(e);
dest.flushSync();
process.exit(1);
}
logger.info('end'); |
I think this should be emphazised in the docs. Would you like to send a PR? Logs are properly flushed when the process normally exists, but in case of an synchronous, abrupt end, you'll need to use |
@mcollina docs are really not clear about this issue so I'm sure they can be improved. But I feel this are all temporary hacks that are not good enough. I don't know why log lose is acceptable in normal mode (documentation make it look like it is only an extreme mode and performance compromise). A user who need high performance can set the level to be higher than fatal (or even Infinity) and a user who cares about accurate logs can set it to 0 and flush on every log |
@mcollina thanks for pointing out that code. I ended up getting the logs to show up using
But then when I tried to use I added a delay in the code before the exit and then I got some error messages from pino around calling flush with |
My solution was to use:
|
@pies I use this code now, but I don't think it is a good idea. |
I'm working to add sync mode to sonic-boom: pinojs/sonic-boom#21. |
I cannot find these commits in pino v5.10.0 npm package, have you release correct code? |
I can confirm that issue is still present in v5.10.0. |
@ajkaushik Yes, npm package v5.10.0 doesn't contain this fix. If you install from this git repo branch master, you can verify it has been fixed. |
I believe this is just a mistake. And we can wait fix.
…On Wed, Dec 12, 2018, 13:10 Ajay Kaushik ***@***.*** wrote:
@zyf0330 <https://github.com/zyf0330> Thanks for the information, but I
am about to make pino as one of my production dependency. And would like to
use correct version from npm itself.
@mcollina <https://github.com/mcollina> Hey would you have any update on
this or pointers to any optional flag we need to turn on?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#542 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ALZ5gQW0QrAVGULOvy6YiHUyp9WcAAeCks5u4I-4gaJpZM4YRxLt>
.
|
Yes it was a mistake (cc @davidmarkclements :P). Released as v5.10.1. I unpublished v5.10.0. |
@mcollina Can you share this mistake, because I cannot image how it happened? Thanks! |
@davidmarkclements did not do any pull before releasing. |
Thanks for the update, I can confirm that behavior is as expected in v5.10.1 and logs are getting flushed correctly. |
I'm logging a quick exit message after a config check (if no config found then log a helpful message). I've taken the above advice and used pino.final, but this fails with a SonicBoom exception thrown by the following:
Full stacktrace is:
So I understand the rationale behind the exception, but cannot work out how to log the error AND exit with a "1". A viable solution is to add a |
This issue is about a long unmaintained version. If you are having a problem with a current version of Pino, please open a new issue or participate in one that is relative and current. |
If I use process exit after a log the log entry is missing -
Expected Output -
Actual output -
I also tried without setting the destination but result is the same.
I think this might be a regression of #458 though I'm not sure if it worked on previous v5 versions
The text was updated successfully, but these errors were encountered: