Closed andrewthad closed 7 years ago
Yes. Please send me a PR.
I tried replicating the problem in a smaller project, and I can't. Browsing the source code, it actually looks like withFastLogger
should already be triggering a flush because it calls rmLoggerSet
at the end. I'm going to close this because I suspect that my larger project actually has something else wrong with it.
I have an application that looks like this:
However, the program terminates without all logs getting flushed to stdout. I think that a better behavior for
withFastLogger
would be to flush when it terminates. I can implement this without changing the existing api. Here is my plan: add an unexported functionnewFastLoggerInternal
that returns a triple that includes theLoggerSet
. This function would basically have the same implementation asnewFastLogger
currently does. Then, reimplementnewFastLogger
to simply call this function and discard theLoggerSet
. Then, reimplementwithFastLogger
to call this new function and flush on exit. I would adjust the logger functions that provide timestamps as well. Let me know if this is acceptable, and I can PR it.