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

Class Logger

Filterer --+
           |
          Logger


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.
Method Summary
  __init__(self, name, level)
Initialize the logger with a name and an optional level.
  addHandler(self, hdlr)
Add the specified handler to this logger.
  callHandlers(self, record)
Pass a record to all relevant handlers.
  critical(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'CRITICAL'.
  debug(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'DEBUG'.
  error(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'ERROR'.
  exception(self, msg, *args)
Convenience method for logging an ERROR with exception information.
  fatal(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'CRITICAL'.
  findCaller(self)
Find the stack frame of the caller so that we can note the source file name and line number.
  getEffectiveLevel(self)
Get the effective level for this logger.
  handle(self, record)
Call the handlers for the specified record.
  info(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'INFO'.
  isEnabledFor(self, level)
Is this logger enabled for level 'level'?
  log(self, level, msg, *args, **kwargs)
Log 'msg % args' with the severity 'level'.
  makeRecord(self, name, level, fn, lno, msg, args, exc_info)
A factory method which can be overridden in subclasses to create specialized LogRecords.
  removeHandler(self, hdlr)
Remove the specified handler from this logger.
  setLevel(self, level)
Set the logging level of this logger.
  warn(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'WARNING'.
  warning(self, msg, *args, **kwargs)
Log 'msg % args' with severity 'WARNING'.
    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
Manager manager = <logging.Manager instance at 0x4024b9ac>
RootLogger root = <logging.RootLogger instance at 0x4024b84c>

Method Details

__init__(self, name, level=0)
(Constructor)

Initialize the logger with a name and an optional level.
Overrides:
logging.Filterer.__init__

addHandler(self, hdlr)

Add the specified handler to this logger.

callHandlers(self, record)

Pass a record to all relevant handlers.

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(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)

findCaller(self)

Find the stack frame of the caller so that we can note the source file name and line number.

getEffectiveLevel(self)

Get the effective level for this logger.

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, level)

Is this logger enabled for level 'level'?

log(self, level, msg, *args, **kwargs)

Log 'msg % args' with the severity 'level'.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.log(level, "We have a %s", "mysterious problem", exc_info=1)

makeRecord(self, name, level, fn, lno, msg, args, exc_info)

A factory method which can be overridden in subclasses to create specialized LogRecords.

removeHandler(self, hdlr)

Remove the specified handler from this logger.

setLevel(self, level)

Set the logging level of this logger.

warn(self, msg, *args, **kwargs)

Log 'msg % args' with severity 'WARNING'.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.warning("Houston, we have a %s", "bit of a problem", exc_info=1)

warning(self, msg, *args, **kwargs)

Log 'msg % args' with severity 'WARNING'.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.warning("Houston, we have a %s", "bit of a problem", exc_info=1)

Class Variable Details

manager

Type:
Manager
Value:
<logging.Manager instance at 0x4024b9ac>                               

root

Type:
RootLogger
Value:
<logging.RootLogger instance at 0x4024b84c>                            

Generated by Epydoc 2.0 on Thu Sep 30 14:39:26 2004 http://epydoc.sf.net