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.1.tar.gz (27.4 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.1-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

File details

Details for the file advlog_core-0.2.1.tar.gz.

File metadata

  • Download URL: advlog_core-0.2.1.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for advlog_core-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a5fc7e7438af779642cc68e9e9da121cc63f8ff45d3788626bb71a201d05ba01
MD5 2a2b2180135ef3c314a04e577d32010f
BLAKE2b-256 fa60d61113d7ea1e14645338e8cf8eddd688aaa47083e56e6f2859bb56902210

See more details on using hashes here.

Provenance

The following attestation bundles were made for advlog_core-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: advlog_core-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 39.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for advlog_core-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e16264c0193abd53da172be98e9d67acb57e0f8c221387219474dd688bf2204
MD5 6cd75e2fefcd8469c33f89cb1e692df3
BLAKE2b-256 66903b0a746394c96b383207d07c89bf46063976c4fe2b55108b51ccacf5197e

See more details on using hashes here.

Provenance

The following attestation bundles were made for advlog_core-0.2.1-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