Logging control plane and unifier
Project description
Drop-in logging foundation for Python projects.
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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logspark-0.10.0.tar.gz.
File metadata
- Download URL: logspark-0.10.0.tar.gz
- Upload date:
- Size: 36.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cadbc88bf62d5589d9c7cc8484ff12f9e21d184e36597f923a0e6ebd7963289d
|
|
| MD5 |
e1b3e604826fb988f461fabd98126d96
|
|
| BLAKE2b-256 |
93bbdd3d3c5a3d2e0b55595104e619f9709b5edad981ca217fe02dba2f0ff0e5
|
Provenance
The following attestation bundles were made for logspark-0.10.0.tar.gz:
Publisher:
ci.yml on Kydoimos97/LogSpark
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logspark-0.10.0.tar.gz -
Subject digest:
cadbc88bf62d5589d9c7cc8484ff12f9e21d184e36597f923a0e6ebd7963289d - Sigstore transparency entry: 1237714768
- Sigstore integration time:
-
Permalink:
Kydoimos97/LogSpark@d03f143c8e70e59eaccd4bce4ae801599e3f16c2 -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/Kydoimos97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@d03f143c8e70e59eaccd4bce4ae801599e3f16c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file logspark-0.10.0-py3-none-any.whl.
File metadata
- Download URL: logspark-0.10.0-py3-none-any.whl
- Upload date:
- Size: 52.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fce7542b60d9c0a33dc22cee67efa34780c09bb343057b05d3ee0f5e1ea41c86
|
|
| MD5 |
afa5eb13288b92224b6afc4393b1ebb9
|
|
| BLAKE2b-256 |
cc765524b795454bbd9e35894e67de9928cb7054c9247b8b7513af68b1c748e5
|
Provenance
The following attestation bundles were made for logspark-0.10.0-py3-none-any.whl:
Publisher:
ci.yml on Kydoimos97/LogSpark
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logspark-0.10.0-py3-none-any.whl -
Subject digest:
fce7542b60d9c0a33dc22cee67efa34780c09bb343057b05d3ee0f5e1ea41c86 - Sigstore transparency entry: 1237714777
- Sigstore integration time:
-
Permalink:
Kydoimos97/LogSpark@d03f143c8e70e59eaccd4bce4ae801599e3f16c2 -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/Kydoimos97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@d03f143c8e70e59eaccd4bce4ae801599e3f16c2 -
Trigger Event:
push
-
Statement type: