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.0.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.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lifecyclelogging-2.1.0.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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.0.tar.gz
Algorithm Hash digest
SHA256 ed79f276f58e1c74bd5f3438ec7c7caf3b16679252bcfab6b419fe632594855b
MD5 79abe79b76c92c9f9de1259659140e68
BLAKE2b-256 f9986cf46a6e5ddedc00f05e461fd9397a1866f3cdf73a7c6ffa04fd0b3acd8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lifecyclelogging-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6962d07b5846b9a722cbfa588095fd2d82c31b6dd4c0e6ce15fc868079996ef
MD5 06a18934e569967a8df1010887563d78
BLAKE2b-256 4d2c6b594ebec9496bc4142f79e9dcfe831454afbc924332581bda697c28634f

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