Open leonzz opened 3 years ago
This is kind of why I don't advocate for periodic rotation. The whole point of rotation is to avoid running out of disk space. Plus it keeps the logic simple.
You could avoid rotating an empty log by checking the size yourself before calling rotate, but we can't change the behavior of rotate without potentially breaking people's code (if for some reason someone wanted to rotate an empty file).
The proposed 2 items won't make the logic more complex as they are pretty trivial to add to the current structure. The breaking part could be mitigated by a optional flag.
Adding these would make things easier for people who want to write periodic rotation on top, but much simpler than doing periodic rotation in this package-)
However I do understand your perspective. The use cases of periodic rotation is probably pretty different with what lumberjack was created for. My use case is to form a buffer backed by log files, so I need a way to periodically pop out all content from the buffer.
Hi @natefinch , I understand your perspective but also think rotate periodically is a good feature for many user, and i found a pr https://github.com/natefinch/lumberjack/pull/103. If you need, i can make a pr based on https://github.com/robfig/cron. Can we complete it?
Hi I'm building a periodic logic on top of lumberjack and there're 2 things that might be beneficial to others if implemented in lumberjack:
Rotate()
is triggered from outside (in my case a periodic ticker), avoid rotating when the current log file is empty;Does these features look useful and straightforward enough to add while maintaining simple API?