pycsa.logging_config

Centralised logging configuration for pyCSA runs.

A thin wrapper around stdlib logging that:

  • attaches a timestamped FileHandler to the root logger (so module loggers under pycsa.* and run scripts all propagate up and land in the same log file — the previous per-script setup only captured the caller module’s own __name__ namespace and silently dropped logs from pycsa.core.tile_cache etc.);

  • silences chatty third-party libraries (matplotlib, distributed) by default;

  • returns the log-file path so the caller can include it in startup banners.

Replaces the inline setup_logger previously living in runs/icon_etopo_global.py so other run scripts (and tests that want a file log) can call the same helper without copy-paste.

Functions

configure_logging([log_dir, name_prefix, ...])

Attach a timestamped file handler to the root logger.

pycsa.logging_config.configure_logging(log_dir: Path | str = 'logs', name_prefix: str = 'pycsa_run', level: int = 20, silence: Sequence[str] = ('matplotlib', 'distributed'), fmt: str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt: str = '%Y-%m-%d %H:%M:%S') Path

Attach a timestamped file handler to the root logger.

Parameters:
  • log_dir – Directory for the log file (created if missing).

  • name_prefix – Stem of the log filename. The full filename is {name_prefix}_{YYYYMMDD_HHMMSS}.log.

  • level – Log level for the root logger and the file handler.

  • silence – Logger names whose level is raised to WARNING so they don’t flood the file (matplotlib + Dask distributed by default).

  • fmt – Standard logging.Formatter arguments.

  • datefmt – Standard logging.Formatter arguments.

Returns:

Absolute path to the newly-created log file.

Return type:

Path