Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Logs should be flushed on process exit #19
Comments
|
Thanks for reporting! Hopefully @Shwetajain148 can address this one |
|
HI @adisbladis, As you said that short-lived processes that may crash the server or stop a running application (as per your case) doesn't show anything on process exit. My assumption is that if the application crashes then the logging will not be completed (it seems the desired behavior). Could you please provide more information about your setup and environment so that I can be able to reproduce it at my end and then can work further to resolve it? |
|
I think what he is suggesting is to add some kind of an event listener for process exit. When the event is triggered, we could flush the logs that are in the queue and then continue exiting. |
|
Exactly what @mostlyjason said. All you need to do to reproduce is this: |
|
Hi @adisbladis, I looked at this issue and tried to handle the exit events like process.exit(); or SIGINT i.e. pressing Ctrl+C to terminate the running process but in each case, I found that as soon as the process.exit event gets fired, no more logging takes place. As we are using ajax requests to send logs to Loggly which is an asynchronous operation, exit events will never wait for ajax requests to complete first. Please refer the below link that states Ref: https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_event_exit I dug around and came up with two ideas to implement your feature requests.
I am thinking of to implement one of above approaches. cc: @mostlyjason |
|
I don't think we should ask for user input since many scripts run headless. I like option 1. However, don't stall the exit based on a boolean. Make the best effort to send logs and then exit. |
|
Why not dump remaining entries to a file (possibly user specified) and provide a helper method to flush it upon next startup? |
|
@FDIM sorry I just saw this now. We implemented it this way because that was the proposed solution at the time on winstonjs/winston#228. It seems like this problem is bigger than just the Loggly plugin, it seems to affect winston as a whole and file logging. I hope we can make use of the solution the winston team decides on once it finds a better solution. In the meantime calling a helper function could be a convenient workaround. |
|
Closing this for now feel free to reopen if you have additional discussion |
Currently logs are emitted every 2000ms but not on process exit.
This causes processes that are very short lived (say a bug that crashes the server on startup) to not show anything.
The text was updated successfully, but these errors were encountered: