Log and progress bar manager for console, notebooks, web applications with unified APIs and nested progress tracking.
npx @tessl/cli install tessl/pypi-proglog@0.1.0A comprehensive progress logging system for Python that enables developers to add flexible progress bars and logging capabilities to their applications. Proglog offers unified APIs for displaying progress across different environments including console applications, Jupyter notebooks, and web interfaces, with support for nested progress bars, selective display control, custom callback functions, and integration with popular progress bar libraries like tqdm.
pip install proglogimport proglogCommon imports for basic usage:
from proglog import ProgressLogger, TqdmProgressBarLogger, default_bar_loggerFor notebook integration:
from proglog import notebookfrom proglog import default_bar_logger
import time
def my_routine(iterations=10, logger='bar'):
"""Run several loops to showcase Proglog."""
logger = default_bar_logger(logger) # Create appropriate logger
# Nested progress bars with automatic tracking
for i in logger.iter_bar(iteration=range(iterations)):
for j in logger.iter_bar(animal=["dog", "cat", "rat", "duck"]):
time.sleep(0.02) # simulate some work
# Manual progress updates
logger(message="Processing complete!")
# Run with default tqdm progress bars
my_routine()
# Run silently
my_routine(logger=None)
# Run with custom configuration
from proglog import TqdmProgressBarLogger
custom_logger = TqdmProgressBarLogger(ignored_bars=["animal"])
my_routine(logger=custom_logger)Proglog uses a hierarchical logger architecture that separates concerns:
This design enables maximum reusability across different deployment contexts, allowing users to control which progress bars are displayed without modifying the underlying code, and enabling complex applications to manage multiple concurrent progress tracking operations with hierarchical organization and customizable output formats.
Core logging functionality with state management, message logging, and iteration tracking. Provides the foundation for all other proglog capabilities.
class ProgressLogger:
def __init__(self, init_state=None): ...
def log(self, message): ...
def dump_logs(self, filepath=None): ...
def callback(self, **kw): ...
def store(self, **kw): ...
def iter(self, **kw): ...
def __call__(self, **kw): ...Advanced progress bar functionality with support for multiple named bars, selective display control, and automatic tracking during iteration. Includes both generic bar management and tqdm-powered display.
class ProgressBarLogger(ProgressLogger):
def __init__(self, init_state=None, bars=None, ignored_bars=None,
logged_bars="all", min_time_interval=0, ignore_bars_under=0): ...
def iter_bar(self, bar_prefix="", **kw): ...
def bars_callback(self, bar, attr, value, old_value=None): ...
class TqdmProgressBarLogger(ProgressBarLogger):
def __init__(self, init_state=None, bars=None, leave_bars=False,
ignored_bars=None, logged_bars="all", notebook="default",
print_messages=True, min_time_interval=0, ignore_bars_under=0): ...Redis Queue (RQ) worker integration for progress tracking in distributed job processing environments. Enables progress state persistence and retrieval across worker processes.
class RqWorkerProgressLogger:
def __init__(self, job): ...
def callback(self, **kw): ...
class RqWorkerBarLogger(RqWorkerProgressLogger, ProgressBarLogger):
def __init__(self, job, init_state=None, bars=None, ignored_bars=(),
logged_bars="all", min_time_interval=0): ...def default_bar_logger(logger, bars=None, ignored_bars=None, logged_bars="all",
min_time_interval=0, ignore_bars_under=0):
"""
Factory function to create appropriate logger based on type.
Parameters:
- logger: "bar" for TqdmProgressBarLogger, None for MuteProgressBarLogger,
or existing logger instance
- bars: Bar configuration (None, list, tuple, or dict)
- ignored_bars: Bars to ignore (None, list, or "all_others")
- logged_bars: Bars to log ("all" or list of bar names)
- min_time_interval: Minimum time between updates (seconds)
- ignore_bars_under: Ignore bars with fewer than N items
Returns:
Configured logger instance
"""def notebook(turn="on"):
"""
Configure global notebook mode setting.
Parameters:
- turn: "on" to enable notebook mode, any other value to disable
"""class MuteProgressBarLogger(ProgressBarLogger):
"""Silent progress bar logger that ignores all bars."""
def bar_is_ignored(self, bar): ... # Always returns True__version__: str # Package version string (currently "0.1.12")