Logger#

Logging.

otx.algorithms.anomaly.adapters.anomalib.logger.get_logger(name: str, log_file: Optional[str] = None, log_level: int = 20, file_mode: str = 'w') Logger#

Get logger.

If the logger has not been initialized, this method will initialize the logger by adding one or two handlers, otherwise the initialized logger will be directly returned. During initialization, a StreamHandler will always be added. If log_file is specified and the process rank is 0, a FileHandler will also be added.

Args:

name (str): Logger name. log_file (str | None): The log filename. If specified, a FileHandler

will be added to the logger.

log_level (int): The logger level. Notx that only the process of

rank 0 is affected, and other processes will set the level to “Error” thus be silent most of the time.

file_mode (str): The file mode used in opening log file.

Defaults to ‘w’.

Returns:

logging.Logger: The expected logger.