[Patches] [ python-Patches-921318 ] Patch for Vinay Sajip's Python-logging package

SourceForge.net noreply at sourceforge.net
Mon Jul 12 11:31:43 CEST 2004


Patches item #921318, was opened at 2004-03-22 19:58
Message generated for change (Comment added) made by vsajip
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=921318&group_id=5470

Category: Library (Lib)
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Mark E. Davidson (medavidson)
Assigned to: Vinay Sajip (vsajip)
Summary: Patch for Vinay Sajip's Python-logging package

Initial Comment:
This is a patch for Vinay Sajip's Python-logging
package.  It adds the support for time-based log
rollovers.  Specifically, it adds a new handler called
TimedRotatingFIleHandler.  TimedRotatingFileHandler
works just like the existing RotatingFileHandler,
except that instead of rolling over when the log file
hits a certain size, it rolls over when a time-interval
has occurred.

You can have the log files rollover ever <n> seconds,
minutes, hours, days.  You can have log files rollover
at midnight.  Log files can also roll over on a day of
the week.

The name of the log file is customized to fit the
interval specified.  In other words, it's suffix is
changed to match the interval you asked for.  If you
asked for it to roll over every hour, then the log file
has a suffix with the year, month, day and hour, but if
you roll over on a certain minute, then the suffix also
has the minute.

I had an extended correspondence with Vinay about this
code as I was writing it, so he knows it's coming.

It's been mostly tested, but not every variation has
been exercised.  The rollovers at seconds, minutes,
hours have been exercised, as well as the midnight
rollover, but the not the day of week.  Additionally,
the backupCount variation of the
TimedRotatingFileHandler is somewhat simplistic and not
well tested.

This patch only affects handlers.py.  It does NOT patch
the graphical TkInter-based log configuration utility,
as I ran out of time to work on this and Vinay said he
might change the class layout.



----------------------------------------------------------------------

>Comment By: Vinay Sajip (vsajip)
Date: 2004-07-12 09:31

Message:
Logged In: YES 
user_id=308438

Patch applied in CVS.

----------------------------------------------------------------------

Comment By: Mark E. Davidson (medavidson)
Date: 2004-03-25 19:14

Message:
Logged In: YES 
user_id=877141

jimjjewitt is correct.  I will try to fix these three issues and upload a new 
patch in the next day or so.

----------------------------------------------------------------------

Comment By: Jim Jewett (jimjjewett)
Date: 2004-03-25 16:07

Message:
Logged In: YES 
user_id=764593

(1)
I think the H in the suffixes need to be capitalized.

>>> time.strftime("%Y-%m-%d_%h-%M-%S", tt)
'2004-03-25_-53-07'
>>> time.strftime("%Y-%m-%d_%H-%M-%S", tt)
'2004-03-25_10-53-07'

(2)  
When globbing for old logfiles to delete, please make it more 
specfic.  For instance, all suffixes (for the next century) start 
with "20", so you could use 

    s = glob.glob(self.basFilename + ".20*")  

This will make it a bit less dangerous for someone to copy a 
file as basename.save when they want to save the info for 
debugging later.

(3)  
The midnight and weekly versions should recalculate the 
rolloverAt instead of adding interval.  This will keep them from 
getting out of synch if there is a maintenance window or 
daylight savings time change.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=921318&group_id=5470


More information about the Patches mailing list