Skip to main content

Project-agnostic logging orchestration utilities built on Python's stdlib logging package

Project description

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

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

utilityhub_logging-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

utilityhub_logging-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file utilityhub_logging-0.1.0.tar.gz.

File metadata

  • Download URL: utilityhub_logging-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for utilityhub_logging-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3c3f29c7daaf556c64cb045260d47fe8f9bc51e3d17c647202404180e74e84f1
MD5 4af198c32104f7f4838154f1f64d4381
BLAKE2b-256 246626dcee32b5ac451ff9dab783cdc9656900668f0c3cfa2bceaf7d8238baa5

See more details on using hashes here.

File details

Details for the file utilityhub_logging-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: utilityhub_logging-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for utilityhub_logging-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1dfc236bb5c50dabf3a25c2860f9e3c79c461236aa38eb3d4eb59f15761516f
MD5 12d9f9ec74e91d62ce8e75227dc7735c
BLAKE2b-256 32576f1b607ad7316863c412fe35da57255346b275884228d7d4077ee3b4b0e2

See more details on using hashes here.

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