Package logging :: Class StreamHandler
[show private | hide private]
[frames | no frames]

Class StreamHandler

Filterer --+    
           |    
     Handler --+
               |
              StreamHandler

Known Subclasses:
FileHandler

A handler class which writes logging records, appropriately formatted, to a stream. Note that this class does not close the stream, as sys.stdout or sys.stderr may be used.
Method Summary
  __init__(self, strm)
Initialize the handler.
  emit(self, record)
Emit a record.
  flush(self)
Flushes the stream.
    Inherited from Handler
  acquire(self)
Acquire the I/O thread lock.
  close(self)
Tidy up any resources used by the handler.
  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, strm=None)
(Constructor)

Initialize the handler.

If strm is not specified, sys.stderr is used.
Overrides:
logging.Handler.__init__

emit(self, record)

Emit a record.

If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline [N.B. this may be removed depending on feedback]. If exception information is present, it is formatted using traceback.print_exception and appended to the stream.
Overrides:
logging.Handler.emit

flush(self)

Flushes the stream.
Overrides:
logging.Handler.flush