Logging

class py_kaos_utils.logging.ProgressLogger(count_total: int, checkpoints: int = 10, logger: ~logging.Logger = <RootLogger root (WARNING)>)

Bases: object

Logs the progress of a process by reporting the percentage of completion at a set number of checkpoints.

Example:
>>> p = ProgressLogger(1000, 10)
>>> for count_this_round in [100, 99, 78, 99, 100]:
>>>     p.log_progress(count_this_round)
Parameters
  • count_total (int) – Total number of items to process

  • checkpoints (int) – Number of checkpoints to report progress at (defaults to 10)

  • logger (Logger) – Logger instance to use for reporting progress (defaults to the built-in logger)

log_progress(count_this_round, report=True)

Log the progress of the process

Parameters
  • count_this_round (int) – Number of items processed this round

  • report (bool) – Whether or not to report the progress (defaults to True)

report_progress()

Report the progress of the process based on the current count_processed value