Skip to main content

Logging control plane and unifier

Project description

LogSpark

Tests Coverage PyPI version Python 3.11+ License: MIT

Drop-in logging foundation for Python projects.

Documentation QuickStart


LogSpark is a configuration and integration layer over Python's standard logging module. It adds lifecycle enforcement, environment-aware output policy, and corrected defaults — without replacing stdlib logging or introducing a new API. Every handler, filter, and formatter is a plain stdlib object.

LogSpark Demo

Installation

pip install logspark

Optional extras:

pip install logspark[color]   # Rich terminal output with layout and color
pip install logspark[json]    # Structured single-line JSON output
pip install logspark[trace]   # Datadog DDTrace correlation injection
pip install logspark[all]     # All of the above

Quick Start

Minimal setup

from logspark import logger

logger.configure()
logger.info("Application started")

configure() with no arguments gives you terminal output to stdout, INFO level and above, color if your terminal supports it, compact tracebacks, and relative file paths in log lines.

Set the log level

import logging
from logspark import logger

logger.configure(level=logging.DEBUG)

Standard stdlib level constants and string names both work.

Log exceptions

try:
    result = 1 / 0
except ZeroDivisionError:
    logger.exception("Calculation failed")

Attach structured fields

logger.info("Request completed", extra={
    "method": "GET",
    "path": "/api/users",
    "status": 200,
    "duration_ms": 42,
})

JSON output

import logging
from logspark import logger
from logspark.Handlers import SparkJsonHandler

logger.configure(level=logging.INFO, handler=SparkJsonHandler())
logger.info("Structured record", extra={"env": "production"})

Rich terminal output

import logging
from logspark import logger
from logspark.Handlers.Rich import SparkRichHandler

logger.configure(level=logging.DEBUG, handler=SparkRichHandler())
logger.debug("Rich layout with columns, color, and path resolution")

Silence or unify third-party loggers

import logging
import httpx
from logspark import logger, spark_log_manager

logger.configure()

spark_log_manager.adopt_all()
spark_log_manager.unify(
    copy_spark_logger_config=True,
    level=logging.WARNING,
    propagate=False,
)

Scoped debug level

import logging
from logspark import logger, TempLogLevel
from logspark.Handlers import SparkTerminalHandler

logger.configure(level=logging.INFO, handler=SparkTerminalHandler())

with TempLogLevel(logging.DEBUG):
    logger.debug("Visible only inside this block")

Key features

Feature Description
Lifecycle enforcement configure -> freeze -> use: configuration happens once, explicitly
Output modes Terminal with color or JSON, switchable via environment variable
Traceback control Hide, compact, or full tracebacks per-logger
Scoped debugging Temporarily lower the log level for a block without changing config
Third-party management Suppress or unify noisy loggers without touching their source
stdlib compatibility Every component works standalone with any logging.Logger

Where to call configure()

At process startup, before any other module uses the logger:

# main.py
import logging
from logspark import logger

logger.configure(level=logging.INFO)

from myapp import run
run()

If a log record is emitted before configure(), LogSpark uses a minimal fallback format and emits a one-time warning. It does not silently discard records.


Documentation


License

MIT — see LICENSE for details.

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

logspark-0.11.0.tar.gz (38.2 kB view details)

Uploaded Source

Built Distribution

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

logspark-0.11.0-py3-none-any.whl (53.8 kB view details)

Uploaded Python 3

File details

Details for the file logspark-0.11.0.tar.gz.

File metadata

  • Download URL: logspark-0.11.0.tar.gz
  • Upload date:
  • Size: 38.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for logspark-0.11.0.tar.gz
Algorithm Hash digest
SHA256 8b253400049e5047da14c1e65f2cef47828e15caa54da1b3eb60bf966dc1449e
MD5 54fe0d93d60f9dba4fd53d46c6e0a150
BLAKE2b-256 8fd6389a80a3304a649a2b91a44864a6bcd40d0bec9d48566bd8a5f63ed2e409

See more details on using hashes here.

Provenance

The following attestation bundles were made for logspark-0.11.0.tar.gz:

Publisher: ci.yml on Kydoimos97/LogSpark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logspark-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: logspark-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 53.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for logspark-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37d873d5396b0f5de3561933189b7bd881658f5ebdcd660d349610fc0a3b9131
MD5 1234a5e1bd027b4918db903e1578b15b
BLAKE2b-256 54d91bf737feb13ba6339fc27f27c82f2c228a22924b25a3f52471c80020ac78

See more details on using hashes here.

Provenance

The following attestation bundles were made for logspark-0.11.0-py3-none-any.whl:

Publisher: ci.yml on Kydoimos97/LogSpark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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