So I just discovered that the #Python build-in logging
module already has a way to rotate logs, and I don't need to handle copy/rename/delete files.
This comes as I realized that a long-running process stops logging precisely when I manually rotate the log file, like it looses the handle to the file (as it does not exists, it's called different after the rename) and does not try to check if there is any other file called the same.
Anyway, I'll refactor the logging system in my #Janitor and #EchoBot bots, to support the built-in TimedRotatingFileHandler