logging.Logger¶
-
class
logging.Logger(name, level=0)[source]¶ 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.
Methods¶
__format__ |
default object formatter |
__init__(name[, level]) |
Initialize the logger with a name and an optional level. |
__new__((S, ...) |
|
__reduce__ |
helper for pickle |
__reduce_ex__ |
helper for pickle |
__sizeof__(() -> int) |
size of object in memory, in bytes |
__subclasshook__ |
Abstract classes can override this to customize issubclass(). |
_log(level, msg, args[, exc_info, extra]) |
Low-level logging routine which creates a LogRecord and then calls all the handlers of this logger to handle the record. |
addFilter(filter) |
Add the specified filter to this handler. |
addHandler(hdlr) |
Add the specified handler to this logger. |
callHandlers(record) |
Pass a record to all relevant handlers. |
critical(msg, *args, **kwargs) |
Log ‘msg % args’ with severity ‘CRITICAL’. |
debug(msg, *args, **kwargs) |
Log ‘msg % args’ with severity ‘DEBUG’. |
error(msg, *args, **kwargs) |
Log ‘msg % args’ with severity ‘ERROR’. |
exception(msg, *args, **kwargs) |
Convenience method for logging an ERROR with exception information. |
fatal(msg, *args, **kwargs) |
Log ‘msg % args’ with severity ‘CRITICAL’. |
filter(record) |
Determine if a record is loggable by consulting all the filters. |
findCaller() |
Find the stack frame of the caller so that we can note the source file name, line number and function name. |
getChild(suffix) |
Get a logger which is a descendant to this one. |
getEffectiveLevel() |
Get the effective level for this logger. |
handle(record) |
Call the handlers for the specified record. |
info(msg, *args, **kwargs) |
Log ‘msg % args’ with severity ‘INFO’. |
isEnabledFor(level) |
Is this logger enabled for level ‘level’? |
log(level, msg, *args, **kwargs) |
Log ‘msg % args’ with the integer severity ‘level’. |
makeRecord(name, level, fn, lno, msg, args, ...) |
A factory method which can be overridden in subclasses to create specialized LogRecords. |
removeFilter(filter) |
Remove the specified filter from this handler. |
removeHandler(hdlr) |
Remove the specified handler from this logger. |
setLevel(level) |
Set the logging level of this logger. |
warn(msg, *args, **kwargs) |
Log ‘msg % args’ with severity ‘WARNING’. |
warning(msg, *args, **kwargs) |
Log ‘msg % args’ with severity ‘WARNING’. |