sopel-irc / sopel

:robot::speech_balloon: An easy-to-use and highly extensible IRC Bot framework. Formerly Willie.
https://sopel.chat
Other
951 stars 405 forks source link

Automatically clean up old log files #2609

Open dgw opened 1 month ago

dgw commented 1 month ago

Requested Feature

Sopel should clean up log files older than some default number of days, with a configuration option to override it.

Problems Solved

Our main Sopel instance started spitting out errors tonight when its jail ran out of disk quota. This feature would prevent similar issues from happening to other users who don't set up an external mechanism to prune logs.

Alternatives

As alluded to above, a cron job or other recurring task could take care of this—at the cost of extra effort from the bot owner.

Notes

The TimedRotatingFileHandler's backupCount option would be a simple way to implement this.

SnoopJ commented 1 month ago

Not sure if the option has been suggested previously but the logging module has handlers that can rotate based on time and/or size, they might be suitable for an in-band solution to the problem (i.e. not needing to get an external check involved)

dgw commented 1 month ago

Sopel already uses TimedRotatingFileHandler to get a new log file each day. It's just not configured to delete old logs, ever, so they build up indefinitely. Our main instance has had raw and debug logs turned on for a long time, which made it a problem much faster than it should ever impact normal use. 😁