logging (version 0.4.6, 8 July 2002)
index
g:\projects\rdc\python\logging.py

Logging module for Python. Based on PEP 282 and comments thereto in
comp.lang.python, and influenced by Apache's log4j system.
 
Should work under Python versions >= 1.5.2, except that source line
information is not available unless 'inspect' is.
 
Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.
 
To use, simply 'import logging' and log away!

 
Modules
            
cPickle
cStringIO
inspect
os
socket
string
sys
thread
threading
time
types

 
Classes
            
BufferingFormatter
Filter
Filterer
Handler
BufferingHandler
MemoryHandler
HTTPHandler
NTEventLogHandler
SMTPHandler
SocketHandler
DatagramHandler
StreamHandler
FileHandler
SysLogHandler
Logger
RootLogger
Formatter
LogRecord
Manager
PlaceHolder

 
class BufferingFormatter
      A formatter suitable for formatting a number of records.
 
  
__init__(self, linefmt=None)
Optionally specify a formatter which will be used to format each
individual record.
format(self, records)
Format the specified records and return the result as a string.
formatFooter(self, records)
Return the footer string for the specified records.
formatHeader(self, records)
Return the header string for the specified records.

 
class BufferingHandler(Handler)
      A handler class which buffers logging records in memory. Whenever each
record is added to the buffer, a check is made to see if the buffer should
be flushed. If it should, then flush() is expected to do the needful.
 
  
__init__(self, capacity)
Initialize the handler with the buffer size.
acquire(self) from Handler
addFilter(self, filter) from Filterer
close(self) from Handler
createLock(self) from Handler
emit(self, record)
Append the record. If shouldFlush() tells us to, call flush() to process
the buffer.
filter(self, record) from Filterer
flush(self)
Override to implement custom flushing behaviour. This version just zaps
the buffer to empty.
format(self, record) from Handler
handle(self, record) from Handler
handleError(self) from Handler
release(self) from Handler
removeFilter(self, filter) from Filterer
setFormatter(self, fmt) from Handler
setLevel(self, lvl) from Handler
shouldFlush(self, record)
Returns true if the buffer is up to capacity. This method can be
overridden to implement custom flushing strategies.

 
class DatagramHandler(SocketHandler)
      A handler class which writes logging records, in pickle format, to
a datagram socket. Note that the very simple wire protocol used means
that packet sizes are expected to be encodable within 16 bits
(i.e. < 32767 bytes).
 
  
__init__(self, host, port)
Initializes the handler with a specific host address and port.
acquire(self) from Handler
addFilter(self, filter) from Filterer
close(self) from SocketHandler
createLock(self) from Handler
emit(self, record) from SocketHandler
filter(self, record) from Filterer
flush(self) from Handler
format(self, record) from Handler
handle(self, record) from Handler
handleError(self) from SocketHandler
makePickle(self, record) from SocketHandler
makeSocket(self)
The factory method of SocketHandler is here overridden to create
a UDP socket (SOCK_DGRAM).
release(self) from Handler
removeFilter(self, filter) from Filterer
send(self, s)
Send a pickled string to a socket. This function allows for
partial sends which can happen when the network is busy.
setFormatter(self, fmt) from Handler
setLevel(self, lvl) from Handler

 
class FileHandler(StreamHandler)
      A handler class which writes formatted logging records to disk files.
 
  
__init__(self, filename, mode='a+')
Open the specified file and use it as the stream for logging.
By default, the file grows indefinitely. You can call setRollover()
to allow the file to rollover at a predetermined size.
acquire(self) from Handler
addFilter(self, filter) from Filterer
close(self)
Closes the stream.
createLock(self) from Handler
doRollover(self)
Do a rollover, as described in setRollover().
emit(self, record)
Output the record to the file, catering for rollover as described
in setRollover().
filter(self, record) from Filterer
flush(self) from StreamHandler
format(self, record) from Handler
handle(self, record) from Handler
handleError(self) from Handler
release(self) from Handler
removeFilter(self, filter) from Filterer
setFormatter(self, fmt) from Handler
setLevel(self, lvl) from Handler
setRollover(self, maxBytes, backupCount)
Set the rollover parameters so that rollover occurs whenever the
current log file is nearly maxBytes in length. If backupCount
is >= 1, the system will successively create new files with the
same pathname as the base file, but with extensions ".1", ".2"
etc. appended to it. For example, with a backupCount of 5 and a
base file name of "app.log", you would get "app.log", "app.log.1",
"app.log.2", ... through to "app.log.5". When the last file reaches
its size limit, the logging reverts to "app.log" which is truncated
to zero length. If maxBytes is zero, rollover never occurs.

 
class Filter
      The base filter class. Loggers and Handlers can optionally use Filter
instances to filter records as desired. The base filter class only allows
events which are below a certain point in the logger hierarchy. For
example, a filter initialized with "A.B" will allow events logged by
loggers "A.B", "A.B.C", "A.B.C.D", "A.B.D" etc. but not "A.BB", "B.A.B"
etc. If initialized with the empty string, all events are passed.
 
  
__init__(self, name='')
Initialize with the name of the logger which, together with its
children, will have its events allowed through the filter. If no
name is specified, allow every event.
filter(self, record)
Is the specified record to be logged? Returns 0 for no, nonzero for
yes. If deemed appropriate, the record may be modified in-place.

 
class Filterer
      A base class for loggers and handlers which allows them to share
common code.
 
  
__init__(self)
Initialize the list of filters to be an empty list.
addFilter(self, filter)
Add the specified filter to this handler.
filter(self, record)
Determine if a record is loggable by consulting all the filters. The
default is to allow the record to be logged; any filter can veto this
and the record is then dropped. Returns a boolean value.
removeFilter(self, filter)
Remove the specified filter from this handler.

 
class Formatter
      Formatters need to know how a LogRecord is constructed. They are
responsible for converting a LogRecord to (usually) a string which can
be interpreted by either a human or an external system. The base Formatter
allows a formatting string to be specified. If none is supplied, the
default value of "%s(message)\n" is used.
 
The Formatter can be initialized with a format string which makes use of
knowledge of the LogRecord attributes - e.g. the default value mentioned
above makes use of the fact that the user's message and arguments are pre-
formatted into a LogRecord's message attribute. Currently, the useful
attributes in a LogRecord are described by:
 
%(name)s            Name of the logger (logging channel)
%(levelno)s         Numeric logging level for the message (DEBUG, INFO,
                    WARN, ERROR, CRITICAL)
%(levelname)s       Text logging level for the message ("DEBUG", "INFO",
                    "WARN", "ERROR", "CRITICAL")
%(pathname)s        Full pathname of the source file where the logging
                    call was issued (if available)
%(filename)s        Filename portion of pathname
%(module)s          Module (name portion of filename)
%(lineno)d          Source line number where the logging call was issued
                    (if available)
%(created)f         Time when the LogRecord was created (time.time()
                    return value)
%(asctime)s         Textual time when the LogRecord was created
%(msecs)d           Millisecond portion of the creation time
%(relativeCreated)d Time in milliseconds when the LogRecord was created,
                    relative to the time the logging module was loaded
                    (typically at application startup time)
%(thread)d          Thread ID (if available)
%(message)s         The result of record.getMessage(), computed just as
                    the record is emitted
 
  
__init__(self, fmt=None, datefmt=None)
Initialize the formatter either with the specified format string, or a
default as described above. Allow for specialized date formatting with
the optional datefmt argument (if omitted, you get the ISO8601 format).
format(self, record)
The record's attribute dictionary is used as the operand to a
string formatting operation which yields the returned string.
Before formatting the dictionary, a couple of preparatory steps
are carried out. The message attribute of the record is computed
using LogRecord.getMessage(). If the formatting string contains
"%(asctime)", formatTime() is called to format the event time.
If there is exception information, it is formatted using
formatException() and appended to the message.
formatException(self, ei)
Format the specified exception information as a string. This
default implementation just uses traceback.print_exception()
formatTime(self, record, datefmt=None)
This method should be called from format() by a formatter which
wants to make use of a formatted time. This method can be overridden
in formatters to provide for any specific requirement, but the
basic behaviour is as follows: if datefmt (a string) is specified,
it is used with time.strftime() to format the creation time of the
record. Otherwise, the ISO8601 format is used. The resulting
string is returned. This function uses a user-configurable function
to convert the creation time to a tuple. By default, time.localtime()
is used; to change this for a particular formatter instance, set the
'converter' attribute to a function with the same signature as
time.localtime() or time.gmtime(). To change it for all formatters,
for example if you want all logging times to be shown in GMT,
set the 'converter' attribute in the Formatter class.

 
class HTTPHandler(Handler)
      A class which sends records to a Web server, using either GET or
POST semantics.
 
  
__init__(self, host, url, method='GET')
Initialize the instance with the host, the request URL, and the method
("GET" or "POST")
acquire(self) from Handler
addFilter(self, filter) from Filterer
close(self) from Handler
createLock(self) from Handler
emit(self, record)
Send the record to the Web server as an URL-encoded dictionary
filter(self, record) from Filterer
flush(self) from Handler
format(self, record) from Handler
handle(self, record) from Handler
handleError(self) from Handler
release(self) from Handler
removeFilter(self, filter) from Filterer
setFormatter(self, fmt) from Handler
setLevel(self, lvl) from Handler

 
class Handler(Filterer)
      The base handler class. Acts as a placeholder which defines the Handler
interface. Handlers can optionally use Formatter instances to format
records as desired. By default, no formatter is specified; in this case,
the 'raw' message as determined by record.message is logged.
 
  
__init__(self, level=0)
Initializes the instance - basically setting the formatter to None
and the filter list to empty.
acquire(self)
Acquire the I/O thread lock.
addFilter(self, filter) from Filterer
close(self)
Tidy up any resources used by the handler. This version does
nothing and is intended to be implemented by subclasses.
createLock(self)
Acquire a thread lock for serializing access to the underlying I/O.
emit(self, record)
Do whatever it takes to actually log the specified logging record.
This version is intended to be implemented by subclasses and so
raises a NotImplementedError.
filter(self, record) from Filterer
flush(self)
Ensure all logging output has been flushed. This version does
nothing and is intended to be implemented by subclasses.
format(self, record)
Do formatting for a record - if a formatter is set, use it.
Otherwise, use the default formatter for the module.
handle(self, record)
Conditionally emit the specified logging record, depending on
filters which may have been added to the handler. Wrap the actual
emission of the record with acquisition/release of the I/O thread
lock.
handleError(self)
This method should be called from handlers when an exception is
encountered during an emit() call. By default it does nothing,
because by default raiseExceptions is false, which means that
exceptions get silently ignored. This is what is mostly wanted
for a logging system - most users will not care about errors in
the logging system, they are more interested in application errors.
You could, however, replace this with a custom handler if you wish.
release(self)
Release the I/O thread lock.
removeFilter(self, filter) from Filterer
setFormatter(self, fmt)
Set the formatter for this handler.
setLevel(self, lvl)
Set the logging level of this handler.

 
class LogRecord
      LogRecord instances are created every time something is logged. They
contain all the information pertinent to the event being logged. The
main information passed in is in msg and args, which are combined
using str(msg) % args to create the message field of the record. The
record also includes information such as when the record was created,
the source line where the logging call was made, and any exception
information to be logged.
 
  
__init__(self, name, lvl, pathname, lineno, msg, args, exc_info)
Initialize a logging record with interesting information.
__str__(self)
getMessage(self)
Return the message for this LogRecord, merging any user-supplied
arguments with the message.

 
class Logger(Filterer)
      Instances of the Logger class represent a single logging channel. A
"logging channel" indicates an area of an application. Exactly how an
"area" is defined is up to the application developer. Since an
application can have any number of areas, logging channels are identified
by a unique string. Application areas can be nested (e.g. an area
of "input processing" might include sub-areas "read CSV files", "read
XLS files" and "read Gnumeric files"). To cater for this natural nesting,
channel names are organized into a namespace hierarchy where levels are
separated by periods, much like the Java or Python package namespace. So
in the instance given above, channel names might be "input" for the upper
level, and "input.csv", "input.xls" and "input.gnu" for the sub-levels.
There is no arbitrary limit to the depth of nesting.
 
  
__init__(self, name, level=0)
Initialize the logger with a name and an optional level.
_log(self, lvl, msg, args, exc_info=None)
Low-level logging routine which creates a LogRecord and then calls
all the handlers of this logger to handle the record.
addFilter(self, filter) from Filterer
addHandler(self, hdlr)
Add the specified handler to this logger.
callHandlers(self, record)
Loop through all handlers for this logger and its parents in the
logger hierarchy. If no handler was found, output a one-off error
message to sys.stderr. Stop searching up the hierarchy whenever a
logger with the "propagate" attribute set to zero is found - that
will be the last logger whose handlers are called.
critical(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'CRITICAL'. To pass exception
information, use the keyword argument exc_info with a true value, e.g.
 
logger.critical("Houston, we have a %s", "major disaster", exc_info=1)
debug(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'DEBUG'. To pass exception information,
use the keyword argument exc_info with a true value, e.g.
 
logger.debug("Houston, we have a %s", "thorny problem", exc_info=1)
error(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'ERROR'. To pass exception information,
use the keyword argument exc_info with a true value, e.g.
 
logger.error("Houston, we have a %s", "major problem", exc_info=1)
exception(self, msg, *args)
Convenience method for logging an ERROR with exception information
fatal = critical(self, msg, *args, **kwargs)
filter(self, record) from Filterer
findCaller(self)
Find the stack frame of the caller so that we can note the source
file name and line number.
getEffectiveLevel(self)
Loop through this logger and its parents in the logger hierarchy,
looking for a non-zero logging level. Return the first one found.
handle(self, record)
Call the handlers for the specified record. This method is used for
unpickled records received from a socket, as well as those created
locally. Logger-level filtering is applied.
info(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'INFO'. To pass exception information,
use the keyword argument exc_info with a true value, e.g.
 
logger.info("Houston, we have a %s", "interesting problem", exc_info=1)
isEnabledFor(self, lvl)
Is this logger enabled for level lvl?
log(self, lvl, msg, *args, **kwargs)
Log 'msg % args' with the severity 'lvl'. To pass exception
information, use the keyword argument exc_info with a true value, e.g.
logger.log(lvl, "We have a %s", "mysterious problem", exc_info=1)
makeRecord(self, name, lvl, fn, lno, msg, args, exc_info)
A factory method which can be overridden in subclasses to create
specialized LogRecords.
removeFilter(self, filter) from Filterer
removeHandler(self, hdlr)
Remove the specified handler from this logger.
setLevel(self, lvl)
Set the logging level of this logger.
warn(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'WARN'. To pass exception information,
use the keyword argument exc_info with a true value, e.g.
 
logger.warn("Houston, we have a %s", "bit of a problem", exc_info=1)

 
class Manager
      There is [under normal circumstances] just one Manager instance, which
holds the hierarchy of loggers.
 
  
__init__(self, root)
Initialize the manager with the root node of the logger hierarchy.
_fixupChildren(self, ph, alogger)
Ensure that children of the placeholder ph are connected to the
specified logger.
_fixupParents(self, alogger)
Ensure that there are either loggers or placeholders all the way
from the specified logger to the root of the logger hierarchy.
getLogger(self, name)
Get a logger with the specified name (channel name), creating it
if it doesn't yet exist. If a PlaceHolder existed for the specified
name [i.e. the logger didn't exist but a child of it did], replace
it with the created logger and fix up the parent/child references
which pointed to the placeholder to now point to the logger.

 
class MemoryHandler(BufferingHandler)
      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.
 
  
__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. Note that without a
target being set either here or via setTarget(), a MemoryHandler
is no use to anyone!
acquire(self) from Handler
addFilter(self, filter) from Filterer
close(self)
Flush, set the target to None and lose the buffer.
createLock(self) from Handler
emit(self, record) from BufferingHandler
filter(self, record) from Filterer
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.
format(self, record) from Handler
handle(self, record) from Handler
handleError(self) from Handler
release(self) from Handler
removeFilter(self, filter) from Filterer
setFormatter(self, fmt) from Handler
setLevel(self, lvl) from Handler
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.

 
class NTEventLogHandler(Handler)
      A handler class which sends events to the NT Event Log. Adds a
registry entry for the specified application name. If no dllname is
provided, win32service.pyd (which contains some basic message
placeholders) is used. Note that use of these placeholders will make
your event logs big, as the entire message source is held in the log.
If you want slimmer logs, you have to pass in the name of your own DLL
which contains the message definitions you want to use in the event log.
 
  
__init__(self, appname, dllname=None, logtype='Application')
acquire(self) from Handler
addFilter(self, filter) from Filterer
close(self)
You can remove the application name from the registry as a
source of event log entries. However, if you do this, you will
not be able to see the events as you intended in the Event Log
Viewer - it needs to be able to access the registry to get the
DLL name.
createLock(self) from Handler
emit(self, record)
Determine the message ID, event category and event type. Then
log the message in the NT event log.
filter(self, record) from Filterer
flush(self) from Handler
format(self, record) from Handler
getEventCategory(self, record)
Return the event category for the record. Override this if you
want to specify your own categories. This version returns 0.
getEventType(self, record)
Return the event type for the record. Override this if you want
to specify your own types. This version does a mapping using the
handler's typemap attribute, which is set up in __init__() to a
dictionary which contains mappings for DEBUG, INFO, WARN, ERROR
and CRITICAL. If you are using your own levels you will either need
to override this method or place a suitable dictionary in the
handler's typemap attribute.
getMessageID(self, record)
Return the message ID for the event record. If you are using your
own messages, you could do this by having the msg passed to the
logger being an ID rather than a formatting string. Then, in here,
you could use a dictionary lookup to get the message ID. This
version returns 1, which is the base message ID in win32service.pyd.
handle(self, record) from Handler
handleError(self) from Handler
release(self) from Handler
removeFilter(self, filter) from Filterer
setFormatter(self, fmt) from Handler
setLevel(self, lvl) from Handler

 
class PlaceHolder
      PlaceHolder instances are used in the Manager logger hierarchy to take
the place of nodes for which no loggers have been defined [FIXME add
example].
 
  
__init__(self, alogger)
Initialize with the specified logger being a child of this placeholder.
append(self, alogger)
Add the specified logger as a child of this placeholder.

 
class RootLogger(Logger)
      A root logger is not that different to any other logger, except that
it must have a logging level and there is only one instance of it in
the hierarchy.
 
  
__init__(self, lvl)
Initialize the logger with the name "root".
_log(self, lvl, msg, args, exc_info=None) from Logger
addFilter(self, filter) from Filterer
addHandler(self, hdlr) from Logger
callHandlers(self, record) from Logger
critical(self, msg, *args, **kwargs) from Logger
debug(self, msg, *args, **kwargs) from Logger
error(self, msg, *args, **kwargs) from Logger
exception(self, msg, *args) from Logger
fatal = critical(self, msg, *args, **kwargs) from Logger
filter(self, record) from Filterer
findCaller(self) from Logger
getEffectiveLevel(self) from Logger
handle(self, record) from Logger
info(self, msg, *args, **kwargs) from Logger
isEnabledFor(self, lvl) from Logger
log(self, lvl, msg, *args, **kwargs) from Logger
makeRecord(self, name, lvl, fn, lno, msg, args, exc_info) from Logger
removeFilter(self, filter) from Filterer
removeHandler(self, hdlr) from Logger
setLevel(self, lvl) from Logger
warn(self, msg, *args, **kwargs) from Logger

 
class SMTPHandler(Handler)
      A handler class which sends an SMTP email for each logging event.
 
  
__init__(self, mailhost, fromaddr, toaddrs, subject)
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.
acquire(self) from Handler
addFilter(self, filter) from Filterer
close(self) from Handler
createLock(self) from Handler
emit(self, record)
Format the record and send it to the specified addressees.
filter(self, record) from Filterer
flush(self) from Handler
format(self, record) from Handler
getSubject(self, record)
If you want to specify a subject line which is record-dependent,
override this method.
handle(self, record) from Handler
handleError(self) from Handler
release(self) from Handler
removeFilter(self, filter) from Filterer
setFormatter(self, fmt) from Handler
setLevel(self, lvl) from Handler

 
class SocketHandler(Handler)
      A handler class which writes logging records, in pickle format, to
a streaming socket. The socket is kept open across logging calls.
If the peer resets it, an attempt is made to reconnect on the next call.
Note that the very simple wire protocol used means that packet sizes
are expected to be encodable within 16 bits (i.e. < 32767 bytes).
 
  
__init__(self, host, port)
Initializes the handler with a specific host address and port.
The attribute 'closeOnError' is set to 1 - which means that if
a socket error occurs, the socket is silently closed and then
reopened on the next logging call.
acquire(self) from Handler
addFilter(self, filter) from Filterer
close(self)
Closes the socket.
createLock(self) from Handler
emit(self, record)
Pickles the record and writes it to the socket in binary format.
If there is an error with the socket, silently drop the packet.
If there was a problem with the socket, re-establishes the
socket.
filter(self, record) from Filterer
flush(self) from Handler
format(self, record) from Handler
handle(self, record) from Handler
handleError(self)
An error has occurred during logging. Most likely cause -
connection lost. Close the socket so that we can retry on the
next event.
makePickle(self, record)
Pickles the record in binary format with a length prefix, and
returns it ready for transmission across the socket.
makeSocket(self)
A factory method which allows subclasses to define the precise
type of socket they want.
release(self) from Handler
removeFilter(self, filter) from Filterer
send(self, s)
Send a pickled string to the socket. This function allows for
partial sends which can happen when the network is busy.
setFormatter(self, fmt) from Handler
setLevel(self, lvl) from Handler

 
class StreamHandler(Handler)
      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.
 
  
__init__(self, strm=None)
If strm is not specified, sys.stderr is used.
acquire(self) from Handler
addFilter(self, filter) from Filterer
close(self) from Handler
createLock(self) from Handler
emit(self, 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.
filter(self, record) from Filterer
flush(self)
Flushes the stream.
format(self, record) from Handler
handle(self, record) from Handler
handleError(self) from Handler
release(self) from Handler
removeFilter(self, filter) from Filterer
setFormatter(self, fmt) from Handler
setLevel(self, lvl) from Handler

 
class SysLogHandler(Handler)
      A handler class which sends formatted logging records to a syslog
server. Based on Sam Rushing's syslog module:
http://www.nightmare.com/squirl/python-ext/misc/syslog.py
Contributed by Nicolas Untz (after which minor refactoring changes
have been made).
 
  
__init__(self, address=('localhost', 514), facility=1)
If address is specified as a string, UNIX socket is used.
If facility is not specified, LOG_USER is used.
acquire(self) from Handler
addFilter(self, filter) from Filterer
close(self)
Closes the socket.
createLock(self) from Handler
emit(self, record)
The record is formatted, and then sent to the syslog server. If
exception information is present, it is NOT sent to the server.
encodePriority(self, facility, priority)
Encode the facility and priority. You can pass in strings or
integers - if strings are passed, the facility_names and
priority_names mapping dictionaries are used to convert them to
integers.
filter(self, record) from Filterer
flush(self) from Handler
format(self, record) from Handler
handle(self, record) from Handler
handleError(self) from Handler
release(self) from Handler
removeFilter(self, filter) from Filterer
setFormatter(self, fmt) from Handler
setLevel(self, lvl) from Handler

 
Functions
            
_acquireLock()
Acquire the module-level lock for serializing access to shared data.
This should be released with _releaseLock().
_releaseLock()
Release the module-level lock acquired by calling _acquireLock().
addLevelName(lvl, levelName)
Associate 'levelName' with 'lvl'. This is used when converting levels
to text during message formatting.
basicConfig()
Do basic configuration for the logging system by creating a
StreamHandler with a default Formatter and adding it to the
root logger.
critical(msg, *args, **kwargs)
Log a message with severity 'CRITICAL' on the root logger.
debug(msg, *args, **kwargs)
Log a message with severity 'DEBUG' on the root logger.
disable(level)
Disable all logging calls less severe than 'level'.
error(msg, *args, **kwargs)
Log a message with severity 'ERROR' on the root logger.
exception(msg, *args)
Log a message with severity 'ERROR' on the root logger,
with exception information.
fatal = critical(msg, *args, **kwargs)
Log a message with severity 'CRITICAL' on the root logger.
fileConfig(fname)
Read the logging configuration from a ConfigParser-format file. This can
be called several times from an application, allowing an end user the
ability to select from various pre-canned configurations (if the
developer provides a mechanism to present the choices and load the chosen
configuration).
In versions of ConfigParser which have the readfp method [typically
shipped in 2.x versions of Python], you can pass in a file-like object
rather than a filename, in which case the file-like object will be read
using readfp.
getLevelName(lvl)
Return the textual representation of logging level 'lvl'. If the level is
one of the predefined levels (CRITICAL, ERROR, WARN, INFO, DEBUG) then you
get the corresponding string. If you have associated levels with names
using addLevelName then the name you have associated with 'lvl' is
returned. Otherwise, the string "Level %s" % lvl is returned.
getLogger(name=None)
Return a logger with the specified name, creating it if necessary.
If no name is specified, return the root logger.
getRootLogger()
Return the root logger. Note that getLogger('') now does the same thing,
so this function is deprecated and may disappear in the future.
info(msg, *args, **kwargs)
Log a message with severity 'INFO' on the root logger.
listen(port=9030)
Start up a socket server on the specified port, and listen for new
configurations. These will be sent as a file suitable for processing
by fileConfig(). Returns a Thread object on which you can call start()
to start the server, and which you can join() when appropriate.
To stop the server, call stopListening().
setLoggerClass(klass)
Set the class to be used when instantiating a logger. The class should
define __init__() such that only a name argument is required, and the
__init__() should call Logger.__init__()
shutdown()
Perform any cleanup actions in the logging system (e.g. flushing
buffers). Should be called at application exit.
stopListening()
Stop the listening server which was created with a call to listen().
warn(msg, *args, **kwargs)
Log a message with severity 'WARN' on the root logger.

 
Data
             ALL = 0
BASIC_FORMAT = '%(levelname)s:%(name)s:%(message)s'
CRITICAL = 50
DEBUG = 10
DEFAULT_HTTP_LOGGING_PORT = 9022
DEFAULT_LOGGING_CONFIG_PORT = 9030
DEFAULT_SOAP_LOGGING_PORT = 9023
DEFAULT_TCP_LOGGING_PORT = 9020
DEFAULT_UDP_LOGGING_PORT = 9021
ERROR = 40
FATAL = 50
INFO = 20
SYSLOG_UDP_PORT = 514
WARN = 30
__author__ = 'Vinay Sajip <vinay_sajip@red-dove.com>'
__date__ = '8 July 2002'
__file__ = r'G:\Projects\RDC\Python\logging.pyc'
__name__ = 'logging'
__status__ = 'alpha'
__version__ = '0.4.6'
_defaultFormatter = <logging.Formatter instance>
_handlers = {}
_levelNames = {0: 'ALL', 10: 'DEBUG', 20: 'INFO', 30: 'WARN', 40: 'ERROR', 50: 'CRITICAL', 'ALL': 0, 'CRITICAL': 50, 'DEBUG': 10, 'ERROR': 40, ...}
_listener = None
_lock = None
_srcfile = r'g:\projects\rdc\python\logging.py'
_startTime = 1026085170.876
raiseExceptions = 0
root = <logging.RootLogger instance>

 
Author
             Vinay Sajip <vinay_sajip@red-dove.com>