logging --- Logging facility for Python — Module-Level Functions

In addition to the classes described above, there are a number of module-level functions.

Return a logger with the specified name or, if name is None, return the root logger of the hierarchy. If specified, the name is typically a dot-separated hierarchical name like 'a', 'a.b' or 'a.b.c.d'. Choice of these names is entirely up to the developer who is using logging, though it is recommended that name be used unless you have a specific reason for not doing that, as mentioned in logger.

All calls to this function with a given name return the same logger instance. This means that logger instances never need to be passed between different parts of an application.

Return either the standard Logger class, or the last class passed to setLoggerClass. This function may be called from within a new class definition, to ensure that installing a customized Logger class will not undo customizations already applied by other code. For example

Return a callable which is used to create a LogRecord.

See setLogRecordFactory for more information about the how the factory is called.

This is a convenience function that calls Logger.debug, on the root logger. The handling of the arguments is in every way identical to what is described in that method.

The only difference is that if the root logger has no handlers, then basicConfig is called, prior to calling debug on the root logger.

For very short scripts or quick demonstrations of logging facilities, debug and the other module-level functions may be convenient. However, most programs will want to carefully and explicitly control the logging configuration, and should therefore prefer creating a module-level logger and calling Logger.debug (or other level-specific methods) on it, as described at the beginning of this documentation.

Logs a message with level INFO on the root logger. The arguments and behavior are otherwise the same as for debug.

Logs a message with level WARNING on the root logger. The arguments and behavior are otherwise the same as for debug.

Logs a message with level ERROR on the root logger. The arguments and behavior are otherwise the same as for debug.

Logs a message with level CRITICAL on the root logger. The arguments and behavior are otherwise the same as for debug. …