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

Class SMTPHandler

Filterer --+    
           |    
     Handler --+
               |
              SMTPHandler


A handler class which sends an SMTP email for each logging event.
Method Summary
  __init__(self, mailhost, fromaddr, toaddrs, subject)
Initialize the handler.
  date_time(self)
Return the current date and time formatted for a MIME header.
  emit(self, record)
Emit a record.
  getSubject(self, record)
Determine the subject for the email.
    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.
  flush(self)
Ensure all logging output has been flushed.
  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.

Class Variable Summary
list monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'J...
list weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',...

Method Details

__init__(self, mailhost, fromaddr, toaddrs, subject)
(Constructor)

Initialize the handler.

Initialize the instance with the from and to addresses and subject line of the email. To specify a non-standard SMTP port, use the (host, port) tuple format for the mailhost argument.
Overrides:
logging.Handler.__init__

date_time(self)

Return the current date and time formatted for a MIME header. Needed for Python 1.5.2 (no email package available)

emit(self, record)

Emit a record.

Format the record and send it to the specified addressees.
Overrides:
logging.Handler.emit

getSubject(self, record)

Determine the subject for the email.

If you want to specify a subject line which is record-dependent, override this method.

Class Variable Details

monthname

Type:
list
Value:
[None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']         

weekdayname

Type:
list
Value:
['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']