Skip to main content

rse-logging

RSE standard logging package for Python APIs.

Features:

  • colored console logs
  • request correlation id with ContextVar
  • FastAPI middleware for X-Correlation-ID
  • helper functions: log_info, log_warning, log_error
  • Telegram alerts for ERROR logs in stg and prd
  • Telegram credentials loaded from HashiCorp Vault

The middleware uses Starlette directly and does not pin the consuming service's FastAPI version. Compatibility is tested with FastAPI 0.115.14 and 0.141.1. FastAPI is a development dependency for these integration tests.

Usage

from fastapi import FastAPI
from rse_logging import CorrelationIdMiddleware, log_error, setup_logger

setup_logger("my-api")

app = FastAPI()
app.add_middleware(CorrelationIdMiddleware)

log_error("startup", "Example error")

Diagnostics

To debug Telegram/Vault configuration without printing tokens:

from rse_logging import diagnose_telegram, setup_logger

setup_logger("my-api")
print(diagnose_telegram(send_test_message=True))

Set RSE_LOGGING_DEBUG=true to print skipped Telegram alert reasons to stderr.

Vault

Telegram alerts are enabled only when RSE_ENV is stg or prd.

The package reads Vault using:

  • RSE_ENV as the KV v2 mount point
  • RSE_VAULT_HOST as the Vault URL
  • RSE_VAULT_TOKEN as the Vault token
  • shared as the default secret path

Expected keys:

telegram_bot_token
telegram_chat_id

Examples:

stg/shared.telegram_bot_token
stg/shared.telegram_chat_id
prd/shared.telegram_bot_token
prd/shared.telegram_chat_id

Set RSE_LOGGING_TELEGRAM_ENABLED=false to disable Telegram alerts.

Metadata

Release files for rse-logging 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rse-logging 0.1.7
File Size Uploaded Provenance Actions
rse_logging-0.1.7.tar.gz 5.6 kB Without provenance Details for rse_logging-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rse-logging 0.1.7
File Interpreter ABI Platform Actions
rse_logging-0.1.7-py3-none-any.whl Python 3 none any Details for rse_logging-0.1.7-py3-none-any.whl

Total release size: 11.8 kB

Release files / rse_logging-0.1.7.tar.gz

Download URL rse_logging-0.1.7.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4ee5d87a7acac0608eb78735b7d6af130ec572e730e79e6b99aff2c8496be3e2
BLAKE2b-256 checksum
How to use checksums
dc2bdac07437dcb13dfc17106bd148fb990edc74ce6bc309d7e547abbc48ea8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.0 Windows/10

Release files / rse_logging-0.1.7-py3-none-any.whl

Download URL rse_logging-0.1.7-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a710ebf09e470e785a2549cd5489426602c42fee5039a5ad38c04765b56ee1eb
BLAKE2b-256 checksum
How to use checksums
b4621cbf19e8e6c66108b416fceefc344deb12eb65e3bb3e2468d54233b61a60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.0 Windows/10

Security for rse-logging 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page