Closed sdomino closed 9 years ago
Have you looked at the Close
method? It blocks until all messages have finished writing. This is different from your solution here, but it would work for the example of a CLI program you gave.
I hadn't seen that, and it does appear to accomplish the same thing.
I only see two minor drawbacks; one being that by using that method the logs fill up with - LOG Closing log now, which isn't a huge issue. The only other potential drawback is that each time you want to os.Exit() you'd need to call log.Close() also, which could be solved by a wrapper anywhere you want to do that.
Anyway, thanks for pointing that out. I'll go ahead and use that as it does exactly what I need, and I can work around the above mentioned points.
Thanks
Glad that will work for you. Feel free to open a PR or issue for anything else.
...to allow for a blocking configuration
Sometimes you may want the logger to block and guarantee a write to your file rather than background it (for instance in a CLI once you've run a command the program may exit before the logger has a chance to write logs).
Now you would be able to set
lumber.Blocking = true
to achieve that.