nbiatoolkit.logger
Submodules
Functions
|
Set up a logger object that can be used to log messages to a file and/or console with daily log file rotation. |
Package Contents
- nbiatoolkit.logger.setup_logger(name: str, log_level: str = 'INFO', console_logging: bool = False, log_file: str | None = None, log_dir: str | None = None, log_format: str = '%(asctime)s | %(name)s | %(levelname)s | %(message)s', datefmt: str = '%y-%m-%d %H:%M') logging.Logger[source]
Set up a logger object that can be used to log messages to a file and/or console with daily log file rotation. If passing a log_file, the log file will be created in the current working directory unless a log_dir is provided. The log_file is created with a TimedRotatingFileHandler to rotate the log file daily.
- Parameters:
name (str) – The name of the logger.
log_level (str, optional) – The log level. Defaults to ‘INFO’.
console_logging (bool, optional) – Whether to log to console. Defaults to False.
log_file (str, optional) – The log file name. Defaults to None.
log_dir (str, optional) – The log directory. Defaults to None.
log_format (str, optional) – The log format. Defaults to ‘%(asctime)s | %(name)s | %(levelname)s | %(message)s’.
datefmt (str, optional) – The date format. Defaults to ‘%y-%m-%d %H:%M’.
- Returns:
The logger object.
- Return type:
logger (logging.Logger)