FloodAdaptLogging
FloodAdaptLogging(self,
= None,
file_path: Optional[Path] int = logging.WARNING,
loglevel_console: int = logging.INFO,
loglevel_root: int = logging.DEBUG,
loglevel_files: = _DEFAULT_FORMATTER,
formatter: logging.Formatter list[type[Warning]]] = None,
ignore_warnings: Optional[ )
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
FloodAdaptLogging.add_file_handler(
file_path: Path,int = logging.DEBUG,
loglevel: = None,
formatter: Optional[logging.Formatter] )
Add a file handler to the logger that directs outputs to a the file.
close_files
= []) FloodAdaptLogging.close_files(exclude: List[Path]
Close all file handlers except those in the exclude list.
configure_warnings
FloodAdaptLogging.configure_warnings(str = 'default',
action: type[Warning]] = None,
category: Optional[ )
Configure the behavior of Python warnings.
Parameters
action :
str
= 'default'-
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.
category :
type
[Warning
] = None-
The category of warnings to configure. If not provided, all warnings are configured. categories include DeprecationWarning, UserWarning, RuntimeWarning, etc.
deprecation_warning
str, reason: str) FloodAdaptLogging.deprecation_warning(version:
Log a deprecation warning with reason and the version that will remove it.
getLogger
FloodAdaptLogging.getLogger(str] = None,
name: Optional[int = logging.INFO,
level: )
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.
Parameters
name :
str
= None-
The name of the logger. If not provided, the root logger is returned.
level : (
int
,) = logging.INFO-
The level of the logger. The default is logging.INFO.
Returns
:
logging
.Logger
-
The logger with the specified name.
remove_file_handler
FloodAdaptLogging.remove_file_handler(file_path: Path)
Remove a file handler from the logger, which stops sending logs to that file and closes it.
to_file
FloodAdaptLogging.to_file(
file_path: Path,int = logging.DEBUG,
loglevel: = _DEFAULT_FORMATTER,
formatter: logging.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.