Metadata-Version: 2.4
Name: logiq-sdk
Version: 1.0.0
Summary: Official Python SDK for the LogIQ AI Observability Platform
License: MIT
Keywords: monitoring,observability,logging,apm
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.28
Provides-Extra: asgi
Provides-Extra: flask
Requires-Dist: flask>=2.0; extra == "flask"

# logiq

Official Python SDK for the [LogIQ](https://logiq.thetechvoyager.in) AI observability platform. Batches structured log/error events on a background thread and ships them to your LogIQ project over HTTP.

## Install

```bash
pip install logiq-sdk
```

## Quick start

```python
from logiq import Monitor

monitor = Monitor(
    api_key="<YOUR_API_KEY>",
    base_url="https://your-logiq-backend.example.com",
    service_name="checkout-service",
)

monitor.info("Order placed", operation="create_order", metadata={"order_id": 123})

try:
    ...
except Exception as exc:
    monitor.capture_exception(exc, operation="create_order")
```

Only `WARN` and above are sent by default — pass `min_level="INFO"` (or `"DEBUG"`) to `Monitor(...)` to lower the threshold.

## ASGI / Flask middleware

```python
from logiq import MonitorASGIMiddleware, attach_flask_middleware

# FastAPI / Starlette
app.add_middleware(MonitorASGIMiddleware, monitor=monitor)

# Flask
attach_flask_middleware(app, monitor)
```

## Correlation IDs

```python
from logiq import set_correlation_id, reset_correlation_id, get_correlation_id

token = set_correlation_id("req-123")
try:
    ...
finally:
    reset_correlation_id(token)
```

## Heartbeats

```python
monitor.heartbeat()               # one-off
monitor.start_heartbeat_loop(30)  # periodic, every 30s, stops on monitor.close()
```

## License

MIT
