misc.log.FloodAdaptLogging

misc.log.FloodAdaptLogging(
    self,
    file_path=None,
    loglevel_console=logging.WARNING,
    loglevel_root=logging.INFO,
    loglevel_files=logging.DEBUG,
    formatter=_DEFAULT_FORMATTER,
    ignore_warnings=None,
)

Methods

Name Description
add_file_handler Add a file handler to the logger that directs outputs to a the file.
close_files Close all file handlers except those in the exclude list.
configure_warnings Configure the behavior of Python warnings.
deprecation_warning Log a deprecation warning with reason and the version that will remove it.
getLogger Get a logger with the specified name. If no name is provided, return the root logger.
remove_file_handler Remove a file handler from the logger, which stops sending logs to that file and closes it.
to_file Open a file at filepath to write logs to. Does not affect other loggers.

add_file_handler

misc.log.FloodAdaptLogging.add_file_handler(
    file_path,
    loglevel=logging.DEBUG,
    formatter=None,
)

Add a file handler to the logger that directs outputs to a the file.

close_files

misc.log.FloodAdaptLogging.close_files(exclude=[])

Close all file handlers except those in the exclude list.

configure_warnings

misc.log.FloodAdaptLogging.configure_warnings(action='default', category=None)

Configure the behavior of Python warnings.

Parameters

Name Type Description Default
action str The action to take on warnings. Common actions include ‘ignore’, ‘default’, ‘error’, ‘always’, etc. The default is ‘default’, which shows warnings once per triggering location. 'default'
category type[Warning] The category of warnings to configure. If not provided, all warnings are configured. categories include DeprecationWarning, UserWarning, RuntimeWarning, etc. None

deprecation_warning

misc.log.FloodAdaptLogging.deprecation_warning(version, reason)

Log a deprecation warning with reason and the version that will remove it.

getLogger

misc.log.FloodAdaptLogging.getLogger(name=None, level=None)

Get a logger with the specified name. If no name is provided, return the root logger.

If the logger does not exist, it is created with the specified level. If no level is provided, the logger inherits the level of the root logger.

Parameters

Name Type Description Default
name str The name of the logger. If not provided, the root logger is returned. None
level int The level of the logger. If not provided, the logger inherits the level of the root logger. None

Returns

Name Type Description
logging.Logger The logger with the specified name.

remove_file_handler

misc.log.FloodAdaptLogging.remove_file_handler(file_path)

Remove a file handler from the logger, which stops sending logs to that file and closes it.

to_file

misc.log.FloodAdaptLogging.to_file(
    file_path,
    loglevel=logging.DEBUG,
    formatter=_DEFAULT_FORMATTER,
)

Open a file at filepath to write logs to. Does not affect other loggers.

When the context manager exits (via regular execution or an exception), the file is closed and the handler is removed.

Back to top