Skip to main content

Zero-dependency Python logging handler that ships log events to Supabase in near-realtime, with redaction, backpressure, and a runtime kill switch.

Project description

pymcp_logging

Zero-dependency Python logging handler that ships log events to a Supabase table in near-realtime. Stdlib only — no requests, no httpx.

Features

  • Drop-in logging.Handler for Supabase (PostgREST-compatible).
  • Bounded in-memory queue with a 1.5s / 50-row batch flush.
  • Gzipped NDJSON disk spool when the network is unreachable; auto-replays on recovery.
  • Backpressure: drops debug/info first when the queue fills, keeps warning+.
  • Redaction of common secret keys (password, token, secret, api_key, Authorization, Cookie) and JWT / sb_* / AWS-key value patterns.
  • Stable machine ID (SHA-256 of Windows MachineGuid) + per-process session UUID.
  • Runtime kill switch via a flag file — toggle live streaming without restarting the app.

Install

pip install pymcp_logging

Quick start

import os
import pymcp_logging as plg

os.environ["SUPABASE_URL"] = "https://<project>.supabase.co"
os.environ["SUPABASE_ANON_KEY"] = "<anon-jwt>"

plg.install()  # adds handler to root logger, registers sys.excepthook

import logging
logging.getLogger(__name__).info("hello supabase", extra={"order_id": 42})

Supabase table

Expects a public.logs table with columns roughly: id, ts, level, logger, message, machine_id, session_id, hostname, app_version, extra (jsonb), traceback.

Kill switch

Create or delete the flag file to toggle live streaming at runtime: %LOCALAPPDATA%\PyMCP\livestream_debug.flag (Windows) — checked each flush (~1.5s).

License

MIT

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

pymcp_logging-0.1.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

pymcp_logging-0.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file pymcp_logging-0.1.0.tar.gz.

File metadata

  • Download URL: pymcp_logging-0.1.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for pymcp_logging-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f3218c694dd1a279ff5492dfa84410caf600b17ccc26b2434c175544d4d4bf5f
MD5 4e07c291468f80c145aa60576be6a34b
BLAKE2b-256 f0aa33365439ac38ed08b32f16b6697f8bf7bb9c4d0b9ab80426c32a1c635867

See more details on using hashes here.

File details

Details for the file pymcp_logging-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pymcp_logging-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for pymcp_logging-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4771251fcfbbda2f951641836138f7d68ae0a3c64041961e8bc27ea1f280eeec
MD5 a85c9adaa59d1e8d0615e741d0b5a116
BLAKE2b-256 2ca88342a157e05281540b03fa974e03d0672a26769b9ae85f89de4396c04b2c

See more details on using hashes here.

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