Skip to main content

Structured logging system for Spakky Framework

Project description

spakky-logging

Spakky Framework를 위한 구조화 로깅 시스템입니다. contextvars 기반 로그 컨텍스트 전파, 설정 가능한 formatter(Text, JSON, Pretty), AOP 기반 메서드 호출 로깅, PostProcessor 기반 자동 설정을 제공합니다.

설치

pip install spakky-logging

빠른 시작

1. 플러그인 자동 등록

spakky-loggingload_plugins()를 통해 자동으로 로드됩니다.

app = SpakkyApplication(ApplicationContext()).load_plugins().scan(my_app).start()

2. @logged로 메서드 표시

from spakky.plugins.logging import logged

class UserService:
    @logged()
    async def create_user(self, name: str, password: str) -> User:
        ...

3. 설정(선택)

LoggingConfig로 기본값을 override합니다.

LoggingConfig is loaded as a @Configuration pod and reads SPAKKY_LOGGING__* environment variables through pydantic-settings.

export SPAKKY_LOGGING__LEVEL=10
export SPAKKY_LOGGING__FORMAT=json
export SPAKKY_LOGGING__MASK_KEYS='["password", "token", "secret"]'
export SPAKKY_LOGGING__SLOW_THRESHOLD_MS=500

4. LogContext 전파

모든 log record에 자동 포함될 contextual key-value pair를 바인딩합니다.

from spakky.plugins.logging import LogContext

LogContext.bind(request_id="req-123", user_id="u-456")

with LogContext.scope(trace_id="t-789"):
    # 이 block 안의 모든 log는 trace_id를 포함
    ...

주요 기능

기능 설명
@logged() annotation AOP 기반 method call/result/error 자동 logging
LogContext contextvars 기반 structured context propagation
ContextInjectingFilter 모든 LogRecord에 LogContext value 주입
SpakkyTextFormatter pipe-separated text format
SpakkyJsonFormatter line당 JSON object 하나
SpakkyPrettyFormatter 개발용 ANSI-colored multi-column format
LoggingConfig 중앙 logging configuration용 @Configuration pod
LoggingSetupPostProcessor application start 시 root logger 자동 설정
민감 데이터 masking log output에서 password, token, secret 등을 masking
느린 호출 감지 method execution이 threshold를 넘으면 warning 출력
결과 truncation 긴 return value를 log output에서 truncate

라이선스

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.6.0.tar.gz (10.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.6.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spakky_logging-6.6.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spakky_logging-6.6.0.tar.gz
Algorithm Hash digest
SHA256 fa1dc7ebe5dc1ee1ee23c02dabc3c1daa07d06c2b2ea8b9dd1421b868f488786
MD5 6d6ddbfc2fc8fcae3f7be2000a91def5
BLAKE2b-256 1482d76ca99d4c0294557c255b289356afdb24cd04886583164b931bd88855d8

See more details on using hashes here.

Provenance

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

Publisher: release.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.6.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for spakky_logging-6.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb511352b75075118183199b0a04f75d20cd366fc2cdbced44dc7a63bc54fc43
MD5 3fd04be2d7d80dc6ff7a006823d7e220
BLAKE2b-256 52ce9667e6d347cd9c02e24228b41865bf2ca0b5e319829e8e98c3d5dc60f445

See more details on using hashes here.

Provenance

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

Publisher: release.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