Skip to main content

A comprehensive logging utility for managing application lifecycle logs

Project description

LifecycleLogging

LifecycleLogging Logo

A comprehensive logging utility for managing application lifecycle logs, combining the power of Python's logging with rich output formatting.

Documentation GitHub

Installation

pip install lifecyclelogging

Features

  • Configurable console and file logging outputs
  • Rich formatting for enhanced readability
  • Message storage with context and storage markers
  • Verbosity controls with bypass markers
  • Case-insensitive level filtering for allowed/denied storage rules
  • JSON data attachment support
  • Type-safe implementation
  • Seamless integration with existing logging systems
  • Automatic Gunicorn logger integration

Project Goals

  • Provide a batteries-included logging helper that stays compatible with modern Python releases
  • Keep configuration ergonomic while remaining type-safe and explicit
  • Offer sensible defaults that work locally and in containerized runtimes
  • Deliver reliable automation through testing, linting, and release workflows

Basic Usage

from lifecyclelogging import Logging

# Initialize logger
logger = Logging(
    enable_console=True,  # Enable console output
    enable_file=True,     # Enable file output
    logger_name="my_app"
)

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

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

# With JSON data
logger.logged_statement(
    "Message with data",
    json_data={"key": "value"},
    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 Helpers

logger.register_verbosity_bypass_marker("IMPORTANT")

# Will be 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"]

Gunicorn Integration

When running under Gunicorn, LifecycleLogging automatically detects and inherits Gunicorn's logger configuration:

# The logger will automatically use Gunicorn's handlers if available
logger = Logging(
    enable_console=True,
    enable_file=True
)

Development

# Install development dependencies
pip install -e ".[dev,test,docs]"

# Run tests
make test

# Run linting and type checks
make check

# Build documentation
make docs

License

MIT License - See LICENSE for details.


Happy Logging!

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-202511.7.0.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

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

lifecyclelogging-202511.7.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lifecyclelogging-202511.7.0.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lifecyclelogging-202511.7.0.tar.gz
Algorithm Hash digest
SHA256 c882dc1446ac4ded66a0cefe344e87ec7e985c6d265734330f3f96e38d40df77
MD5 17217f774abbc1a1dce3db2afa490ff7
BLAKE2b-256 3ebad5c2ae8a1763b121ffc9d57da0d56757e99c815cde38d81111e15c8bc6f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lifecyclelogging-202511.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 933557e7d2417de9b127332b3b802e827b985ae7c58789dea84c44d5779d594b
MD5 7e828e3cb083a88b69bd8dd2464285bc
BLAKE2b-256 f9a846175fa251d8702f81e9cc18f6ea5ce7e42dff415e3fc04d5f1c9a34dcde

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