Skip to main content

Centralized log shipping for mgf-common consumers — a fail-open logging handler that batches canonical LogRecord JSON + statistics and POSTs them to a collector over a versioned, language-neutral wire protocol, plus a store-now stub collector. Sibling of mgf-common under the mgf.* namespace.

Project description

mgf-logship

Centralized log shipping for the Magogi federation — the Layer-B half of the unified-logging program (see mgf-common/docs/inprogress/UNIFIED_LOGGING_DESIGN.md, decision D4: ship + protocol now, stub the server).

A consumer attaches LogShipper to its logging tree; it batches the canonical mgf-common LogRecord JSON (the same shape every runtime emits — OB-10), redacts each record, and POSTs them to a collector over a versioned, language-neutral wire protocol. A store-now stub collector (FastAPI + sqlite) is included so the protocol works end-to-end today; analysis and presentation are a later program.

Install

pip install mgf-logship                # shipper only (stdlib transport)
pip install mgf-logship[collector]     # + the FastAPI/sqlite stub collector

Ship logs from an app

import logging
from mgf.logship import LogShipper
from mgf.common.observability import current_log_stats  # optional stats shipping

shipper = LogShipper(
    "https://collector.internal",
    token="…",                       # Authorization: Bearer …
    stats_provider=current_log_stats,  # also ship LogStats every 30s
)
logging.getLogger().addHandler(shipper)
# … on shutdown: shipper.close()  (flushes the queue)

LogShipper is fail-open (a slow/down collector never blocks or crashes the app), bounded (the queue is capped; oldest dropped on overflow, counted in dropped_count), and redacts before ship (off-box data is scrubbed).

Run the stub collector

from mgf.logship.collector import create_collector_app
app = create_collector_app(db_path="logship.db", token="…")
# uvicorn module:app

Endpoints: POST /ingest (NDJSON of LogRecords), POST /stats (a LogStats JSON), GET /health. It persists to sqlite and stops there.

The wire protocol

mgf.logship._protocol is the source of truth: SHIP_PROTOCOL_VERSION, the endpoint paths, the X-Logship-* headers, and the NDJSON framing. Deliberately HTTP + NDJSON so a Zig or TS shipper can talk to the same collector with nothing but a socket and a JSON encoder.

License

MIT — see 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

mgf_logship-0.1.0.tar.gz (64.4 kB view details)

Uploaded Source

Built Distribution

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

mgf_logship-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mgf_logship-0.1.0.tar.gz
  • Upload date:
  • Size: 64.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mgf_logship-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eaa22bcb7d0286e0defc787a18840cdeab1d23d57d2c8256652435f821bbac20
MD5 1b4b92ba4dac868240e6c0b9d86e09b6
BLAKE2b-256 7c9cf517ead84afb5564a37a560765398a183ea0a4bc475b17c9cafd856a8e9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mgf_logship-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mgf_logship-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 741b01a4331d0e6d4159a70c2e7ee8af7b2c71572fd653b14104774fe31727c5
MD5 8858b7e627d5f2cec5612a889bed83d7
BLAKE2b-256 9b434dcf82dba0eb43f44e59f9d6f0a7fcaf24ff0be176de1f227bc8774b3d39

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