Ticket #54 (new wishlist)

Opened 10 years ago

Last modified 10 years ago

logging removal auotmated in logit()

Reported by: paulf Owned by: somebody
Priority: minor Milestone: All Platforms
Component: ALL modules Version:
Keywords: Cc:


Just had an idea while answering a question from stefan for a new mechanism for log roll over for Earthworm. Currently an external module needs to be run to delete log files, but it would be REALLY nice if EW cleaned up its logs after a certain number of days.....this of course should be optional. How to implement it? Well, here is the idea as it stands:

create an EW_LOG_DURATION env var that has the number of days to keep log files for and when a logit() call is done, and its time to open a new file, it also checks to see if this env var is set. If it is not set it does nothing. If it is set, it removes ONLY its logs for the program being logged that are older than that number of days.

This model would result in some delete activity only at the time of new file creation...and would be a nice mechanism to rotate out old logs without having to remember to setup a cron or at job to do something.

Change History

comment:1 Changed 10 years ago by paulf

Comment from David Kragness

You should be aware that doing it this way (adding cleanup inside the logit call) has the ability to add considerable latency to a logit call. 
It won't be very frequent, but most EW applications weren't written with the expectation that a logit() call could take multiple seconds to execute, which would now be possible, especially if someone suddenly turned it on for a directory with a bunch of old files.
Possibly it could be done asynchronously, having logit spawn a separate thread/process to do the cleanup when it does a logfile rollover, such that the impetus is in the logit call, but the actual work gets done in a background thread so as not to extend the duration of the logit call.  (I'm guessing that this would not work for single-threaded library  version logit?)
I'm not saying it's a bad idea, I'm just saying there may be unintended consequences to adding additional processing being done within the logit call.
Note: See TracTickets for help on using tickets.