Skip to main content

A comprehensive logging utility for managing application lifecycle logs

Project description

LifecycleLogging

Lifecycle-aware logging with rich output and message storage.

CI Status PyPI version Python versions

LifecycleLogging is a comprehensive logging utility that combines Python's logging with rich output formatting. It provides configurable console and file outputs, message storage with context markers, verbosity controls, and seamless Gunicorn integration.

Key Features

  • Rich Formatting - Enhanced readability with configurable console and file outputs
  • Message Storage - Store and retrieve messages by context and storage markers
  • Verbosity Control - Fine-grained verbosity thresholds with bypass markers
  • Level Filtering - Case-insensitive allowed/denied storage rules
  • JSON Attachment - Attach structured data to log entries
  • Gunicorn Integration - Automatic logger inheritance when running under Gunicorn
  • Type-Safe - Full type annotations throughout

Installation

pip install lifecyclelogging

Quick Start

from lifecyclelogging import Logging

# Initialize logger
logger = Logging(
    enable_console=True,
    enable_file=True,
    logger_name="my_app"
)

# Basic logging
logger.logged_statement("Basic message", log_level="info")

# With context marker
logger.logged_statement(
    "Application started",
    context_marker="STARTUP",
    log_level="info"
)

# With JSON data
logger.logged_statement(
    "Request received",
    json_data={"method": "GET", "path": "/api/users"},
    log_level="debug"
)

Advanced Features

Verbosity Control

logger = Logging(
    enable_verbose_output=True,
    verbosity_threshold=2
)

# Only logged if verbosity threshold allows
logger.logged_statement(
    "Detailed debug info",
    verbose=True,
    verbosity=2,
    log_level="debug"
)

Verbosity Bypass

logger.register_verbosity_bypass_marker("IMPORTANT")

# Logged regardless of verbosity settings
logger.logged_statement(
    "Critical info",
    context_marker="IMPORTANT",
    verbose=True,
    verbosity=5,
    log_level="debug"
)

Message Storage

# Store message under a marker
logger.logged_statement(
    "Important event",
    storage_marker="EVENTS",
    log_level="info"
)

# Access stored messages
events = logger.stored_messages["EVENTS"]

Contributing

Contributions are welcome! Please see the Contributing Guidelines for more information.

Project Links

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

lifecyclelogging-2.1.1.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

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

lifecyclelogging-2.1.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file lifecyclelogging-2.1.1.tar.gz.

File metadata

  • Download URL: lifecyclelogging-2.1.1.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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":true}

File hashes

Hashes for lifecyclelogging-2.1.1.tar.gz
Algorithm Hash digest
SHA256 623076fc52b4cc7ce204d526c6e715d104a8ab09a4b17f53e1c287d398462b84
MD5 e08326b73bf16f3a90fa8cc841752c27
BLAKE2b-256 45f894c0a867992759ebc21a0e43e04f48d4f7a1914fed07a5b2467233a799d4

See more details on using hashes here.

File details

Details for the file lifecyclelogging-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: lifecyclelogging-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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":true}

File hashes

Hashes for lifecyclelogging-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 55a1fee7c699631f252351ab8941145d8098b460fcd7282fab1e203458c6ee1d
MD5 4f98840711803c9e195d9190de9b0a89
BLAKE2b-256 89ef7486e691e71d8a36b90fe6f397044b7fb58440b9ea429cd3e01778ed0379

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