Structured logging system for Spakky Framework
Project description
spakky-logging
Structured logging system for Spakky Framework. Provides contextvars-based log context propagation, configurable formatters (Text, JSON, Pretty), automatic method call logging with masking and timing via AOP, and auto-configuration via PostProcessor.
Installation
pip install spakky-logging
Quick Start
1. Plugin Auto-Registration
spakky-logging is automatically loaded via load_plugins():
app = SpakkyApplication(ApplicationContext()).load_plugins().scan(my_app).start()
2. Annotate Methods with @Logging
from spakky.plugins.logging import Logging
class UserService:
@Logging()
async def create_user(self, name: str, password: str) -> User:
...
3. Configure (Optional)
Override defaults via LoggingConfig:
from spakky.plugins.logging import LoggingConfig, LogFormat
config = LoggingConfig(
level="DEBUG",
format=LogFormat.JSON,
mask_keys=frozenset({"password", "token", "secret"}),
slow_threshold_ms=500,
)
4. Log Context Propagation
Bind contextual key-value pairs that are automatically included in all log records:
from spakky.plugins.logging import LogContext
LogContext.bind(request_id="req-123", user_id="u-456")
with LogContext.scope(trace_id="t-789"):
# All logs within this block include trace_id
...
Features
| Feature | Description |
|---|---|
@Logging() annotation |
AOP-based automatic method call/result/error logging |
LogContext |
Contextvars-based structured context propagation |
ContextInjectingFilter |
Injects LogContext values into every LogRecord |
SpakkyTextFormatter |
Pipe-separated text format |
SpakkyJsonFormatter |
One JSON object per line |
SpakkyPrettyFormatter |
ANSI-colored multi-column format for development |
LoggingConfig |
@Configuration pod for centralized logging configuration |
LoggingSetupPostProcessor |
Auto-configures root logger on application start |
| Sensitive data masking | Masks password, token, secret etc. in log output |
| Slow call detection | Warns when method execution exceeds threshold |
| Result truncation | Truncates long return values in log output |
License
MIT License
Project details
Release history Release notifications | RSS feed
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 spakky_logging-6.1.1.tar.gz.
File metadata
- Download URL: spakky_logging-6.1.1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af2984fcca2497b07f1808b72a2489e1c5bd1fc1b4215f083be4c841d7891823
|
|
| MD5 |
ff5254a3d570932a2a8e27529faf5756
|
|
| BLAKE2b-256 |
ae617227bc5924497f210a5737e78b8217fccaaf0f8756e8591c9bd0bbb31336
|
Provenance
The following attestation bundles were made for spakky_logging-6.1.1.tar.gz:
Publisher:
release.yml on E5presso/spakky-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spakky_logging-6.1.1.tar.gz -
Subject digest:
af2984fcca2497b07f1808b72a2489e1c5bd1fc1b4215f083be4c841d7891823 - Sigstore transparency entry: 1110093744
- Sigstore integration time:
-
Permalink:
E5presso/spakky-framework@193a772f1b560c3aec0863e54f0a0fb25e12a47b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/E5presso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@193a772f1b560c3aec0863e54f0a0fb25e12a47b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file spakky_logging-6.1.1-py3-none-any.whl.
File metadata
- Download URL: spakky_logging-6.1.1-py3-none-any.whl
- Upload date:
- Size: 14.1 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 |
18a5a15e7162d30a2815ffb73dfff3813610f790c93070422ce9274ccb6c6a1c
|
|
| MD5 |
7188ca238e27f754410f8f6dfb438b90
|
|
| BLAKE2b-256 |
ccc10190adb84b337d899b66fe560145a8d77a534b225a8c350e808fea6c3365
|
Provenance
The following attestation bundles were made for spakky_logging-6.1.1-py3-none-any.whl:
Publisher:
release.yml on E5presso/spakky-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spakky_logging-6.1.1-py3-none-any.whl -
Subject digest:
18a5a15e7162d30a2815ffb73dfff3813610f790c93070422ce9274ccb6c6a1c - Sigstore transparency entry: 1110093749
- Sigstore integration time:
-
Permalink:
E5presso/spakky-framework@193a772f1b560c3aec0863e54f0a0fb25e12a47b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/E5presso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@193a772f1b560c3aec0863e54f0a0fb25e12a47b -
Trigger Event:
workflow_dispatch
-
Statement type: