Skip to main content

utilityhub-logging

utilityhub-logging is a small, project-agnostic package that extends Python's standard library logging module with deterministic setup and cleanup helpers.

It focuses on the repetitive parts teams tend to rebuild:

  • resolving a safe logs directory
  • configuring one log file per application run
  • opening a scoped log for an operation
  • switching between plain text and JSON output
  • attaching async-safe contextual metadata
  • preventing duplicate handlers and cleaning them up reliably

Install

uv add utilityhub-logging

Quick Start

import logging

from utilityhub_logging import (
    LogFormat,
    begin_scope_logging,
    bind_context,
    cleanup_logging,
    configure_app_logging,
)

log_file = configure_app_logging(
    app_name="demo-app",
    level="INFO",
    console=True,
    log_format=LogFormat.PLAIN,
)

logger = logging.getLogger("demo")
with bind_context(environment="dev", subsystem="worker"):
    logger.info("Application started")

scope_logger, scope_file = begin_scope_logging(
    app_name="demo-app",
    scope_type="job",
    scope_id="job-42",
    log_format=LogFormat.JSON,
)
scope_logger.info("Running scoped operation")

cleanup_logging()

Public API

  • resolve_logs_path(...)
  • configure_app_logging(...)
  • begin_scope_logging(...)
  • end_scope_logging(...)
  • bind_context(...)
  • cleanup_logging(...)

Defaults

  • UTF-8 file output
  • timestamped log files in UTC
  • platform-aware default log directories
  • ~/.local/state/<app>/logs on Linux and similar Unix systems
  • ~/Library/Logs/<app> on macOS
  • %LOCALAPPDATA%\<app>\Logs on Windows
  • no current-working-directory logging unless explicitly requested

Metadata

Release files for utilityhub-logging 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for utilityhub-logging 0.1.0
File Size Uploaded
utilityhub_logging-0.1.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for utilityhub-logging 0.1.0
File Interpreter ABI Platform
utilityhub_logging-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / utilityhub_logging-0.1.0.tar.gz

Download URL utilityhub_logging-0.1.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3c3f29c7daaf556c64cb045260d47fe8f9bc51e3d17c647202404180e74e84f1
BLAKE2b-256 checksum
How to use checksums
246626dcee32b5ac451ff9dab783cdc9656900668f0c3cfa2bceaf7d8238baa5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.22 {"installer":{"name":"uv","version":"0.11.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / utilityhub_logging-0.1.0-py3-none-any.whl

Download URL utilityhub_logging-0.1.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1dfc236bb5c50dabf3a25c2860f9e3c79c461236aa38eb3d4eb59f15761516f
BLAKE2b-256 checksum
How to use checksums
32576f1b607ad7316863c412fe35da57255346b275884228d7d4077ee3b4b0e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.22 {"installer":{"name":"uv","version":"0.11.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page