Package logging :: Module handlers :: Class TimedRotatingFileHandler
[hide private]
[frames] | no frames]

_ClassType TimedRotatingFileHandler

Filterer --+                
           |                
     Handler --+            
               |            
   StreamHandler --+        
                   |        
         FileHandler --+    
                       |    
     BaseRotatingHandler --+
                           |
                          TimedRotatingFileHandler

Handler for logging to a file, rotating the log file at certain timed intervals.

If backupCount is > 0, when rollover is done, no more than backupCount files are kept - the oldest ones are deleted.

Instance Methods [hide private]
 
__init__(self, filename, when='h', interval=1, backupCount=0, encoding=None)
Use the specified filename for streamed logging
 
shouldRollover(self, record)
Determine if rollover should occur
 
doRollover(self)
do a rollover; in this case, a date/time stamp is appended to the filename when the rollover happens.

Inherited from BaseRotatingHandler: emit

Inherited from FileHandler: close

Inherited from StreamHandler: flush

Inherited from Handler: acquire, createLock, format, handle, handleError, release, setFormatter, setLevel

Inherited from Filterer: addFilter, filter, removeFilter

Method Details [hide private]

__init__(self, filename, when='h', interval=1, backupCount=0, encoding=None)
(Constructor)

 

Use the specified filename for streamed logging

Overrides: Filterer.__init__
(inherited documentation)

shouldRollover(self, record)

 

Determine if rollover should occur

record is not used, as we are just comparing times, but it is needed so the method siguratures are the same

doRollover(self)

 

do a rollover; in this case, a date/time stamp is appended to the filename when the rollover happens. However, you want the file to be named for the start of the interval, not the current time. If there is a backup count, then we have to get a list of matching filenames, sort them and remove the one with the oldest suffix.