logging

Logging factory and handlers

mio.logging.init_logger(name: str, log_dir: Path | None | bool = None, level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR'] | None = None, file_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR'] | None = None, log_file_n: int | None = None, log_file_size: int | None = None) Logger

Make a logger.

Log to a set of rotating files in the log_dir according to name , as well as using the RichHandler for pretty-formatted stdout logs.

Parameters:
  • name (str) – Name of this logger. Ideally names are hierarchical and indicate what they are logging for, eg. mio.sdcard and don’t contain metadata like timestamps, etc. (which are in the logs)

  • log_dir (pathlib.Path) – Directory to store file-based logs in. If None, get from Config. If False , disable file logging.

  • level (LOG_LEVELS) – Level to use for stdout logging. If None , get from Config

  • file_level (LOG_LEVELS) – Level to use for file-based logging. If None , get from Config

  • log_file_n (int) – Number of rotating file logs to use. If None , get from Config

  • log_file_size (int) – Maximum size of logfiles before rotation. If None , get from Config

Returns:

logging.Logger