Metadata-Version: 2.4
Name: pymcp_logging
Version: 0.1.0
Summary: Zero-dependency Python logging handler that ships log events to Supabase in near-realtime, with redaction, backpressure, and a runtime kill switch.
Author: Caddie253
License: MIT
Project-URL: Homepage, https://codeberg.org/pymcpbrowser/pymcp_logging
Project-URL: Source, https://codeberg.org/pymcpbrowser/pymcp_logging
Keywords: logging,supabase,observability,log-shipper,structured-logging
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Logging
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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

```python
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
