RED4ext icon indicating copy to clipboard operation
RED4ext copied to clipboard

Reimplement log rotation

Open flibdev opened this issue 11 months ago • 6 comments

Only downside of the new timestamped log files is that now some users can have hundreds (or even thousands for some modders/addicts like DBK) of log files clogging up the logs folder.

Could add logic to keep only the last 5-10 logs. Default log rotation with spdlog doesn't work presumably because the log filenames are different

flibdev avatar Mar 23 '24 11:03 flibdev

Maybe add an option to either use log rotation (most common use case) or unique filenames (multiple instance use case)? And by default it could use log rotation.

poirierlouis avatar Mar 23 '24 13:03 poirierlouis

This is something I want to implement, but I don't have much time to do it these days :(

wopss avatar Mar 24 '24 06:03 wopss

This is something I want to implement [...]

You mean about my proposal or this?

Could add logic to keep only the last 5-10 logs.

poirierlouis avatar Mar 24 '24 12:03 poirierlouis

You mean about my proposal or this?

I mean about the original proposal.

Regarding your proposal, I would prefer to stick the timestamp option due to the fact that previously we had many users report errors where the game process did not close properly causing rotation issues.

wopss avatar Mar 24 '24 18:03 wopss

So keep timestamp (multiple instance compatible and prevent errors) while still enabling log rotation? I might look into this, but in this case (due to timestamp) log rotation would be done manually as I believe spdlog don't support this case?

poirierlouis avatar Mar 24 '24 20:03 poirierlouis

So keep timestamp (multiple instance compatible and prevent errors) while still enabling log rotation?

Yes

I might look into this, but in this case (due to timestamp) log rotation would be done manually as I believe spdlog don't support this case?

Yes, we need a custom sink for the logger which will do the rotation for timestamped files. Basically:

  • List all files.
  • Check if they start with logger's name.
  • Try to remove, if fail no problem we try next time.

wopss avatar Mar 24 '24 20:03 wopss