Progress Log Manager
Proglog is a progress logging system for Python (current version 0.1.12). It enables developers to build complex libraries while offering users fine-grained control over logs, callbacks, and progress bars. It is actively maintained with releases focusing on build system improvements and documentation.
Warnings
- gotcha When using `proglog.notebook()` to enable HTML progress bars, this setting applies globally to the current Python process. If different parts of an application (e.g., a script vs. an interactive session within the same process) require different progress bar behaviors (console vs. HTML), this global state can lead to unexpected display modes.
- gotcha In complex applications with nested `iter_bar` calls across multiple libraries, progress bars might interfere with each other if they implicitly use the same internal identifiers. This can lead to incorrect or confusing progress displays, especially if loop variables or names are not unique.
Install
-
pip install proglog
Imports
- default_bar_logger
from proglog import default_bar_logger
- TqdmProgressBarLogger
from proglog import TqdmProgressBarLogger
- notebook
import proglog proglog.notebook()
Quickstart
import time
from proglog import default_bar_logger, TqdmProgressBarLogger
def my_processing_function(data_items=10, logger='bar'):
"""A function that simulates work and uses proglog for progress."""
logger = default_bar_logger(logger) # Initialize logger based on input string or object
results = []
for i in logger.iter_bar(iterable=range(data_items), message="Processing data"): # Use 'iterable' for cleaner iteration
# Simulate some computational work
time.sleep(0.05)
results.append(i * 2)
return results
print("--- Running with default console progress bar ---")
my_processing_function(data_items=5)
print("\n--- Running with TQDM progress bar (explicitly passed) ---")
tqdm_logger_instance = TqdmProgressBarLogger() # Create an instance of a specific logger
my_processing_function(data_items=7, logger=tqdm_logger_instance)
print("\n--- Running with no progress bar ---")
my_processing_function(data_items=3, logger=None)
# To enable notebook specific bars, one would typically call proglog.notebook() once
# at the start of a Jupyter notebook session, before calling functions that use proglog.
# For example:
# import proglog
# proglog.notebook()
# my_processing_function(data_items=5)