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

_ClassType MemoryHandler

Filterer --+        
           |        
     Handler --+    
               |    
BufferingHandler --+
                   |
                  MemoryHandler

A handler class which buffers logging records in memory, periodically flushing them to a target handler. Flushing occurs whenever the buffer is full, or when an event of a certain severity or greater is seen.

Instance Methods [hide private]
 
__init__(self, capacity, flushLevel=40, target=None)
Initialize the handler with the buffer size, the level at which flushing should occur and an optional target.
 
shouldFlush(self, record)
Check for buffer full or a record at the flushLevel or higher.
 
setTarget(self, target)
Set the target handler for this handler.
 
flush(self)
For a MemoryHandler, flushing means just sending the buffered records to the target, if there is one.
 
close(self)
Flush, set the target to None and lose the buffer.

Inherited from BufferingHandler: emit

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

Inherited from Filterer: addFilter, filter, removeFilter

Method Details [hide private]

__init__(self, capacity, flushLevel=40, target=None)
(Constructor)

 

Initialize the handler with the buffer size, the level at which flushing should occur and an optional target.

Note that without a target being set either here or via setTarget(), a MemoryHandler is no use to anyone!

Overrides: Filterer.__init__

shouldFlush(self, record)

 

Check for buffer full or a record at the flushLevel or higher.

Overrides: BufferingHandler.shouldFlush

flush(self)

 

For a MemoryHandler, flushing means just sending the buffered records to the target, if there is one. Override if you want different behaviour.

Overrides: Handler.flush

close(self)

 

Flush, set the target to None and lose the buffer.

Overrides: Handler.close