Advanced logging library with Rich features, progress tracking, and ML training utilities
Project description
advlog
A Python logging library with colored terminal output, file management, progress tracking, and ML training utilities, built on top of Rich.
Personal project notice: This package was written for personal development use. Update frequency and feature scope may be limited. Contributions and suggestions are welcome.
Features
- Rich Console Output — Colored terminal logging via the Rich library
- Flexible Configuration —
LoggerConfigdataclass for per-logger overrides; simpleinitialize()/get_logger()API for common cases - File Logging — Separate or merged file strategies with configurable rotation
- Progress Tracking — Integrated progress bars via
ProgressTracker - Multi-Module Coordination —
LoggerManagerfor consistent logging across modules - ML/Training Utilities —
TrainingLoggerplugin for experiment logging - Smart File Naming — Timestamped, daily, and incremental log file naming
Installation
pip install advlog-core
With all optional features:
pip install "advlog-core[all]"
The PyPI package name is
advlog-core; import asimport advlog.
Quick Start
One-liner
from advlog import get_logger
log = get_logger(__name__)
log.info("Application started")
log.warning("High memory usage detected")
log.error("Database connection failed")
Initialize once, use everywhere
from advlog import initialize, get_logger, get_progress
initialize(
output_dir="./logs",
session_name="myapp",
log_level="DEBUG",
show_location=True,
)
log = get_logger(__name__)
log.info("Initialized")
progress = get_progress()
with progress:
task = progress.add_task("Processing", total=100)
for i in range(100):
progress.update(task, advance=1)
Per-logger configuration with LoggerConfig
from advlog import LoggerManager, LoggerConfig
manager = LoggerManager(shared_console=True, shared_file="logs/app.log")
# Default registration
api_logger = manager.register_logger("api")
# Override with LoggerConfig
db_logger = manager.register_logger(config=LoggerConfig(
name="database",
log_level="DEBUG",
log_file="logs/db.log",
show_location=True,
))
api_logger.info("API server started")
db_logger.debug("Executing query: SELECT ...")
Register a group of loggers at once
from advlog import create_logger_group
loggers = create_logger_group(
["api", "database", "auth"],
shared_console=True,
file_strategy="merged",
)
loggers["api"].info("Request received")
loggers["database"].debug("Query executed")
loggers["auth"].warning("Invalid login attempt")
Formatters
Four formatters are available:
| Class | Description |
|---|---|
RichColorFormatter |
Wraps messages in Rich color markup by log level |
PlainFormatter |
Plain text, no color codes |
IndentedFormatter |
Indents continuation lines of multi-line messages |
JSONFormatter |
Outputs each record as a JSON object |
from advlog import JSONFormatter
import logging
handler = logging.StreamHandler()
handler.setFormatter(JSONFormatter())
logging.getLogger("myapp").addHandler(handler)
File Logging
from advlog import create_file_handler
handler = create_file_handler(
log_file="logs/app.log",
file_mode="a",
show_location=True,
)
Smart log file naming
from advlog import LogNamingStrategy
# Timestamp-based: logs/2026-03-06/20260306_143022_app_prod.log
log_file = LogNamingStrategy.timestamped("app", suffix="prod")
# Daily directory: logs/2026-03-06/myapp_errors.log
log_file = LogNamingStrategy.daily("myapp", suffix="errors")
# Incremental (no conflicts): logs/backup_data.log → backup_data_1.log ...
log_file = LogNamingStrategy.incremental("backup", suffix="data")
Progress Tracking
from advlog import ProgressTracker
with ProgressTracker() as progress:
download = progress.add_task("Downloading", total=100)
process = progress.add_task("Processing", total=50)
for _ in range(100):
progress.update(download, advance=1)
for _ in range(50):
progress.update(process, advance=1)
ML Training Utilities
from advlog import TrainingLogger
import logging
logger = logging.getLogger(__name__)
trainer = TrainingLogger(logger)
trainer.log_train_step(
epoch=1,
total_epochs=10,
batch=100,
total_batches=1000,
loss_dict={"loss": 0.4231, "accuracy": 0.872},
learning_rate=1e-3,
time_elapsed=45.2,
)
Exception Logging
from advlog import setup_exception_logging
# Install a sys.excepthook that logs all uncaught exceptions
setup_exception_logging()
Real-World Example
See examples/real_world_demo/ for a complete multi-module application demonstrating global initialization, cross-module loggers, progress tracking, error handling, and organized file output.
python -m examples.real_world_demo.main
Dependencies
Required
- Rich — Terminal formatting and colored output
Optional
| Extra tag | Package | Feature |
|---|---|---|
config |
omegaconf |
Advanced config file parsing |
torch |
torchinfo |
Model structure visualization |
distributed |
accelerate |
Distributed/multi-GPU training support |
pip install "advlog-core[config]"
pip install "advlog-core[torch]"
pip install "advlog-core[distributed]"
Contributing
Contributions are welcome — please feel free to open an issue or submit a pull request.
License
Apache License 2.0 — see LICENSE for details.
Acknowledgments
- Rich for the terminal formatting library
- Python logging for the logging infrastructure
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file advlog_core-0.2.0.tar.gz.
File metadata
- Download URL: advlog_core-0.2.0.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
430930116a6a45b0d7076b5fac1f0dc110a547566c07eec7bec02c7c484f2b7e
|
|
| MD5 |
c85248ae246215e10cf72980ee41eef5
|
|
| BLAKE2b-256 |
5a59ea4e5c5ee789d58b5152f162dd05b639d41e010bfc7f5b6a7f125251dbfc
|
Provenance
The following attestation bundles were made for advlog_core-0.2.0.tar.gz:
Publisher:
python-publish.yml on mz-wang/advlog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
advlog_core-0.2.0.tar.gz -
Subject digest:
430930116a6a45b0d7076b5fac1f0dc110a547566c07eec7bec02c7c484f2b7e - Sigstore transparency entry: 1049001559
- Sigstore integration time:
-
Permalink:
mz-wang/advlog@77858905ee78ef76c76fca870a413c00f7dda4dd -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/mz-wang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@77858905ee78ef76c76fca870a413c00f7dda4dd -
Trigger Event:
push
-
Statement type:
File details
Details for the file advlog_core-0.2.0-py3-none-any.whl.
File metadata
- Download URL: advlog_core-0.2.0-py3-none-any.whl
- Upload date:
- Size: 39.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f26931c73fddb20c1fe0a569aa0c2e37be5a7ace33cdbd8ce20444f4f8162efb
|
|
| MD5 |
bc775755b1e7cf7a9805763ee4f07f1f
|
|
| BLAKE2b-256 |
7e8fe5ece0adadbef6d6a36d9716ea6e6b0d3777d35028856f0bf3a8c9d3ecb4
|
Provenance
The following attestation bundles were made for advlog_core-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on mz-wang/advlog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
advlog_core-0.2.0-py3-none-any.whl -
Subject digest:
f26931c73fddb20c1fe0a569aa0c2e37be5a7ace33cdbd8ce20444f4f8162efb - Sigstore transparency entry: 1049001612
- Sigstore integration time:
-
Permalink:
mz-wang/advlog@77858905ee78ef76c76fca870a413c00f7dda4dd -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/mz-wang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@77858905ee78ef76c76fca870a413c00f7dda4dd -
Trigger Event:
push
-
Statement type: