Skip to main content

Advanced logging library with Rich features, progress tracking, and ML training utilities

Project description

advlog

Python Version License Version

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 ConfigurationLoggerConfig dataclass for per-logger overrides; simple initialize() / 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 CoordinationLoggerManager for consistent logging across modules
  • ML/Training UtilitiesTrainingLogger plugin 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 as import 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

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

advlog_core-0.2.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

advlog_core-0.2.0-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

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

Hashes for advlog_core-0.2.0.tar.gz
Algorithm Hash digest
SHA256 430930116a6a45b0d7076b5fac1f0dc110a547566c07eec7bec02c7c484f2b7e
MD5 c85248ae246215e10cf72980ee41eef5
BLAKE2b-256 5a59ea4e5c5ee789d58b5152f162dd05b639d41e010bfc7f5b6a7f125251dbfc

See more details on using hashes here.

Provenance

The following attestation bundles were made for advlog_core-0.2.0.tar.gz:

Publisher: python-publish.yml on mz-wang/advlog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for advlog_core-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f26931c73fddb20c1fe0a569aa0c2e37be5a7ace33cdbd8ce20444f4f8162efb
MD5 bc775755b1e7cf7a9805763ee4f07f1f
BLAKE2b-256 7e8fe5ece0adadbef6d6a36d9716ea6e6b0d3777d35028856f0bf3a8c9d3ecb4

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page