Advanced logging library with Rich features, progress tracking, and ML training utilities
Project description
advlog-core
A powerful, feature-rich logging library for Python with beautiful terminal output, flexible configuration, and extensive plugin support.
✨ Features
- 🎨 Rich Console Output - Beautiful colored terminal logging with Rich library
- 📊 Progress Tracking - Integrated progress bars with automatic management
- 🔧 Flexible Configuration - Easy-to-use configuration system based on dataclasses
- 📁 Smart File Management - Log rotation, intelligent naming, and multiple file strategies
- 🎯 Multi-Module Coordination - LoggerManager for unified logging across modules
- 🔍 Source Information - Automatic display of log origin (file, line, function)
- 📐 Aligned Formatting - Precise control over field width and alignment
- 🌍 Environment Adaptive - Automatic detection and adaptation to different environments
- 🚀 ML/AI Ready - Built-in support for machine learning training logs
📦 Installation
Install from PyPI:
pip install advlog-core
Install with all optional features:
pip install "advlog-core[all]"
Note: The PyPI package name is
advlog-core, but when importing in Python, useimport advlog.
🚀 Quick Start
Basic Usage
from advlog import get_logger
# Create a logger for the current module
log = get_logger(__name__)
# Use the logger
log.info("Application started")
log.warning("High memory usage detected")
log.error("Database connection failed")
Initialize Logging System
from advlog import initialize, get_logger, get_progress
# Initialize the logging system
initialize(
output_dir="./logs",
session_name="myapp",
log_level="DEBUG",
show_location=True
)
# Get logger and progress tracker
log = get_logger(__name__)
progress = get_progress()
# Use in a workflow
with progress:
task = progress.add_task("Processing", total=100)
for i in range(100):
# Do work
progress.update(task, advance=1)
🏗️ Real-World Example
For a complete multi-module application example, see examples/real_world_demo/. This demonstrates:
- Global logging initialization - Set up logging once at application start
- Cross-module logging - Share loggers across multiple Python files
- Progress tracking - Track long-running workflows
- Error handling - Comprehensive error logging
- File management - Organized log file structure
Run it:
python -m examples.real_world_demo.main
📋 Advanced Usage
Multiple Loggers with Manager
from advlog import LoggerManager, get_logger
# Create a logger manager for coordinated logging
manager = LoggerManager(shared_console=True)
# Register loggers for different modules
api_logger = manager.register_logger("api")
db_logger = manager.register_logger("database", log_level="DEBUG")
auth_logger = manager.register_logger("auth")
# Use them
api_logger.info("API server started")
db_logger.debug("Executing query")
auth_logger.warning("Invalid login attempt")
Smart File Naming
from advlog import LogNamingStrategy
# Timestamp-based naming
log_file = LogNamingStrategy.timestamped("app", suffix="production")
# Result: logs/2026-01-05/20260105_143022_app_production.log
# Daily directory structure
log_file = LogNamingStrategy.daily("myapp", suffix="errors")
# Result: logs/2026-01-05/myapp_errors.log
# Incremental naming (avoids conflicts)
log_file = LogNamingStrategy.incremental("backup", suffix="data")
# Result: logs/backup_data.log (or backup_data_1.log if exists)
Progress Tracking
from advlog import ProgressTracker
with ProgressTracker() as progress:
# Add multiple tasks
download_task = progress.add_task("Downloading files", total=100)
process_task = progress.add_task("Processing data", total=50)
# Update progress
for i in range(100):
# Download file
progress.update(download_task, advance=1)
for i in range(50):
# Process data
progress.update(process_task, advance=1)
ML Training Logger
from advlog import AdvancedLogger, TrainingLogger
# Create logger
logger = AdvancedLogger().get_logger()
# Create training logger
trainer = TrainingLogger(logger)
# Log training step
trainer.log_train_step(
epoch=1,
total_epochs=10,
batch=100,
total_batches=1000,
loss_dict={"loss": 0.5, "accuracy": 0.85},
learning_rate=0.001,
time_elapsed=45.2
)
🛠️ Dependencies
This project is built to be lightweight. While the core functionality requires minimal setup, certain features are enabled only when optional dependencies are installed.
Required
These are necessary for the basic operation of advlog-core:
- Rich (MIT License): Used for beautiful terminal formatting and logging.
Optional
Install these based on your specific use case:
- OmegaConf (BSD-3-Clause): Required for advanced configuration file parsing.
- torchinfo (MIT License): Required for model structure visualization.
- Accelerate (Apache-2.0): Required for distributed training and multi-GPU logging support.
Installation
You can install the core package with:
pip install advlog-core
To include all optional features, you can use the extra tag:
pip install "advlog-core[all]"
Or install specific optional dependencies:
pip install "advlog-core[config]" # For OmegaConf support
pip install "advlog-core[torch]" # For torchinfo support
pip install "advlog-core[distributed]" # For Accelerate support
📖 Documentation
- Examples: See the
examples/directory for various use cases - Changelog: See CHANGELOG.md for version history
- API Reference: Browse the source code in
src/advlog/
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
🙏 Acknowledgments
- Rich - For the amazing 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.1.1.tar.gz.
File metadata
- Download URL: advlog_core-0.1.1.tar.gz
- Upload date:
- Size: 30.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cb06cdce75060328926a2cd3c849df480d7810c0d948ed4111a74953f8a6b3d
|
|
| MD5 |
aefcea79cd8ffd0f0448ebd58852da83
|
|
| BLAKE2b-256 |
4df883bb9293ce853ccf226603580880192e836414d79a840bd2366d7e274340
|
Provenance
The following attestation bundles were made for advlog_core-0.1.1.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.1.1.tar.gz -
Subject digest:
3cb06cdce75060328926a2cd3c849df480d7810c0d948ed4111a74953f8a6b3d - Sigstore transparency entry: 1002914610
- Sigstore integration time:
-
Permalink:
mz-wang/advlog@e3c9f61f88e2ee298a28dd5e0fb6b0cc44393b33 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mz-wang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e3c9f61f88e2ee298a28dd5e0fb6b0cc44393b33 -
Trigger Event:
release
-
Statement type:
File details
Details for the file advlog_core-0.1.1-py3-none-any.whl.
File metadata
- Download URL: advlog_core-0.1.1-py3-none-any.whl
- Upload date:
- Size: 46.0 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 |
ca9695f40bcb48dde7e0814a6d1a2017fcc26a2a8c7a68980b5b71bae0d15878
|
|
| MD5 |
40207c178b8bbfcda5fcef180f496b1f
|
|
| BLAKE2b-256 |
285c1a8d517ec945315285f8c8fe664524790a042998de7a5d30d91b34a41593
|
Provenance
The following attestation bundles were made for advlog_core-0.1.1-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.1.1-py3-none-any.whl -
Subject digest:
ca9695f40bcb48dde7e0814a6d1a2017fcc26a2a8c7a68980b5b71bae0d15878 - Sigstore transparency entry: 1002914614
- Sigstore integration time:
-
Permalink:
mz-wang/advlog@e3c9f61f88e2ee298a28dd5e0fb6b0cc44393b33 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mz-wang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e3c9f61f88e2ee298a28dd5e0fb6b0cc44393b33 -
Trigger Event:
release
-
Statement type: