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

Class 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.
Method Summary
  __init__(self, capacity, flushLevel, target)
Initialize the handler with the buffer size, the level at which flushing should occur and an optional target.
  close(self)
Flush, set the target to None and lose the buffer.
  flush(self)
For a MemoryHandler, flushing means just sending the buffered records to the target, if there is one.
  setTarget(self, target)
Set the target handler for this handler.
  shouldFlush(self, record)
Check for buffer full or a record at the flushLevel or higher.
    Inherited from BufferingHandler
  emit(self, record)
Emit a record.
    Inherited from Handler
  acquire(self)
Acquire the I/O thread lock.
  createLock(self)
Acquire a thread lock for serializing access to the underlying I/O.
  format(self, record)
Format the specified record.
  handle(self, record)
Conditionally emit the specified logging record.
  handleError(self, record)
Handle errors which occur during an emit() call.
  release(self)
Release the I/O thread lock.
  setFormatter(self, fmt)
Set the formatter for this handler.
  setLevel(self, level)
Set the logging level of this handler.
    Inherited from Filterer
  addFilter(self, filter)
Add the specified filter to this handler.
  filter(self, record)
Determine if a record is loggable by consulting all the filters.
  removeFilter(self, filter)
Remove the specified filter from this handler.

Method Details

__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:
logging.handlers.BufferingHandler.__init__

close(self)

Flush, set the target to None and lose the buffer.
Overrides:
logging.handlers.BufferingHandler.close

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:
logging.handlers.BufferingHandler.flush

setTarget(self, target)

Set the target handler for this handler.

shouldFlush(self, record)

Check for buffer full or a record at the flushLevel or higher.
Overrides:
logging.handlers.BufferingHandler.shouldFlush