On Oct 24, 2012, at 10:22 AM, David M Chess <ch...@us.ibm.com> wrote:

> >> This works great, splitting the log information across files by date, as 
> >> long as the process is actually up at midnight.
> >>
> >> But now the users have noticed that if the process isn't up at midnight, 
> >> they can end up with lines from two (or I guess potentially more) dates in 
> >> the same log file.
> >>
> >> Is there some way to fix this, either with cleverer arguments into the 
> >> TimedRotatingFileHandler, or by some plausible subclassing of it or its 
> >> superclass? 
> 
> Tx, 
> DC 


(After a VERY brief scan of the logging cookbook and modules.)
I don't think you have any choice but brute force.  If the program
wasn't up at midnight, then somehow it got restarted. You will have
to add logic to the restart code (or to the program itself that gets
run as it initializes).

Something like:

Does a log file exist? -> No ->  First run; create log file & continue
          |
         Yes
          |
  Read backwards looking for date change, copy lines after change
  to new file, delete from old file.

-Bill
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to