Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spakky_logging-6.0.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

spakky_logging-6.0.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file spakky_logging-6.0.0.tar.gz.

File metadata

  • Download URL: spakky_logging-6.0.0.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

Hashes for spakky_logging-6.0.0.tar.gz
Algorithm Hash digest
SHA256 9c03d9e701298062a51eab8632b31977b7613f6e514c776b73dd8d837fc7766e
MD5 da64f51c5352626a548d67d2f3bbf24e
BLAKE2b-256 9eb5eb2e144cf6c838f205d8812a1e7182bd5665dcd9cbc3556ea0e5541078cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for spakky_logging-6.0.0.tar.gz:

Publisher: publish-package.yml on E5presso/spakky-framework

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

File details

Details for the file spakky_logging-6.0.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for spakky_logging-6.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a99646a7961a4a4068712f717f3a117904bbf4b9cba9be28f07e22bacf1025a0
MD5 9777f138aa532250182d867f21ccb192
BLAKE2b-256 f15da86bb67b0b7588e43534efbf3cc58b8dc49a2b460780f318f23b52596204

See more details on using hashes here.

Provenance

The following attestation bundles were made for spakky_logging-6.0.0-py3-none-any.whl:

Publisher: publish-package.yml on E5presso/spakky-framework

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