logging#

class FileHandler(filename, mode='a', encoding=None, delay=False, errors=None)#

Bases: FileHandler

class MuteConsoleFilter(name='')#

Bases: Filter

filter(record)#

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

class QueueHandler(queue)#

Bases: QueueHandler

class QueueListener(queue, *handlers, respect_handler_level=False)#

Bases: QueueListener

class StreamHandler(stream=None)#

Bases: StreamHandler

canary_stream = True#
emit(record)#

Emit a 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. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.

class Formatter(**kwargs)#

Bases: Formatter

format(record)#

Format the specified record as text.

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 uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

class JsonFormatter(**kwargs)#

Bases: Formatter

format(record)#

Format the specified record as text.

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 uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

level_name_mapping() dict[int, str]#
class ProgressMonitor(logger_name: str, message: str, levelno: int = 20)#

Bases: object

done(status: str = 'done') None#
class CanaryLogger(name, level=0)#

Bases: Logger

progress_monitor(message: str, levelno: int = 20) ProgressMonitor#
class AdaptiveDebugLogger(name: str, min_interval: float = 10.0, max_interval: float = 120.0, growth: float = 1.6)#

Bases: object

Dynamic debug logger that starts chatty and backs off exponentially while conditions remain unchanged. Resets immediately on state change.

emit(signature: tuple[Any, ...], msg: str) None#
get_logger(name: str | None = None) CanaryLogger#
get_level_name(levelno: int | None = None) str#
get_levelno(levelname: str) int#
set_level(level: int | str, only: Literal['stream', 'file'] | None = None) int | None#
setup_logging() None#
stream_handler(levelno: int = 20) StreamHandler#
json_file_handler(file: str | Path, levelno: int = 0) FileHandler#
add_handler(handler: Handler) None#
clear_handlers() None#
level_color(levelno: int) str#
get_level() int#
info(*args, **kwargs)#
warning(*args, **kwargs)#
error(*args, **kwargs)#
critical(*args, **kwargs)#
exception(*args, **kwargs)#