Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
logging.handlers.MemoryHandler Class Reference
Inheritance diagram for logging.handlers.MemoryHandler:
Inheritance graph
[legend]
Collaboration diagram for logging.handlers.MemoryHandler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def shouldFlush
def setTarget
def flush
def close
def emit

Public Attributes

 flushLevel
 target
 buffer
 capacity

Detailed Description

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.

Definition at line 1109 of file handlers.py.


Constructor & Destructor Documentation

def logging.handlers.MemoryHandler.__init__ (   self,
  capacity,
  flushLevel = logging.ERROR,
  target = None 
)
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!

Definition at line 1115 of file handlers.py.

01115 
01116     def __init__(self, capacity, flushLevel=logging.ERROR, target=None):
01117         """
01118         Initialize the handler with the buffer size, the level at which
01119         flushing should occur and an optional target.
01120 
01121         Note that without a target being set either here or via setTarget(),
01122         a MemoryHandler is no use to anyone!
01123         """
01124         BufferingHandler.__init__(self, capacity)
01125         self.flushLevel = flushLevel
01126         self.target = target

Here is the caller graph for this function:


Member Function Documentation

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

Reimplemented from logging.handlers.BufferingHandler.

Definition at line 1153 of file handlers.py.

01153 
01154     def close(self):
01155         """
01156         Flush, set the target to None and lose the buffer.
01157         """
01158         self.flush()
01159         self.target = None
01160         BufferingHandler.close(self)
01161 

Here is the call graph for this function:

Here is the caller graph for this function:

def logging.handlers.BufferingHandler.emit (   self,
  record 
) [inherited]
Emit a record.

Append the record. If shouldFlush() tells us to, call flush() to process
the buffer.

Reimplemented in test.support.TestHandler.

Definition at line 1081 of file handlers.py.

01081 
01082     def emit(self, record):
01083         """
01084         Emit a record.
01085 
01086         Append the record. If shouldFlush() tells us to, call flush() to process
01087         the buffer.
01088         """
01089         self.buffer.append(record)
01090         if self.shouldFlush(record):
01091             self.flush()

Here is the call graph for this function:

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

The record buffer is also cleared by this operation.

Reimplemented from logging.handlers.BufferingHandler.

Definition at line 1140 of file handlers.py.

01140 
01141     def flush(self):
01142         """
01143         For a MemoryHandler, flushing means just sending the buffered
01144         records to the target, if there is one. Override if you want
01145         different behaviour.
01146 
01147         The record buffer is also cleared by this operation.
01148         """
01149         if self.target:
01150             for record in self.buffer:
01151                 self.target.handle(record)
01152             self.buffer = []

Here is the caller graph for this function:

def logging.handlers.MemoryHandler.setTarget (   self,
  target 
)
Set the target handler for this handler.

Definition at line 1134 of file handlers.py.

01134 
01135     def setTarget(self, target):
01136         """
01137         Set the target handler for this handler.
01138         """
01139         self.target = target

def logging.handlers.MemoryHandler.shouldFlush (   self,
  record 
)
Check for buffer full or a record at the flushLevel or higher.

Reimplemented from logging.handlers.BufferingHandler.

Definition at line 1127 of file handlers.py.

01127 
01128     def shouldFlush(self, record):
01129         """
01130         Check for buffer full or a record at the flushLevel or higher.
01131         """
01132         return (len(self.buffer) >= self.capacity) or \
01133                 (record.levelno >= self.flushLevel)


Member Data Documentation

Reimplemented from logging.handlers.BufferingHandler.

Definition at line 1151 of file handlers.py.

Definition at line 1069 of file handlers.py.

Definition at line 1124 of file handlers.py.

Definition at line 1125 of file handlers.py.


The documentation for this class was generated from the following file: