misc.log.FloodAdaptLogging
misc.log.FloodAdaptLogging(self,
=None,
file_path=logging.WARNING,
loglevel_console=logging.INFO,
loglevel_root=logging.DEBUG,
loglevel_files=_DEFAULT_FORMATTER,
formatter=None,
ignore_warnings )
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,=logging.DEBUG,
loglevel=None,
formatter )
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
='default', category=None) misc.log.FloodAdaptLogging.configure_warnings(action
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
=None, level=None) misc.log.FloodAdaptLogging.getLogger(name
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,=logging.DEBUG,
loglevel=_DEFAULT_FORMATTER,
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.