Open onavratil-monetplus opened 5 days ago
The daily logger has indeed some issues. The queue stuff for example, which means that after app restart/crash, the queue would be empty. Improvements/suggestions/PR are welcome. Breaking changes are also ok since we could have a new daily sink v2 and deprecate the current. For example I dont think it should support max file count as it complicates greatly the implementation and it is really the job of some cron job.
I was experimenting with daily filename rotation, like this:
I wanted to test the rotation, i.e. I set the hour and minute to like ~1-2min ahead, started my app, poked it to produce some logs, and expected to see new file created in the log folder in a few mins.
Which did not happen.
The logger constructor calculates the initial log filename based on current date/time
Then, when rotation occurs, this happens
Once again, the filename is determined by the log entry count, and the date remains unchanged.
This is kind of tricky to figure out, and even harder to debug. I suggest at least to make a documentation entry.
Moreover, in extreme cases, this may lead to unexpected/undefined behavior:
max_files
may cause deletion of an extra file (needs verification)2025-01-01T13:00
will create the2025-01-01.txt
log file. Therotation_tp_
will be2025-01-02T12:00
2025-01-02T12:00
and2025-01-02T23:59
2025-01-03T00:30
. This is clearly afterrotation_tp_
and will cause creation of a new file.01-02
but01-03