Metadata-Version: 2.4
Name: lognexis-py
Version: 1.0.3
Summary: Official Python SDK for LogNexis API Monitoring & Observability
Home-page: https://lognexis.online
Author: Gopal562004
Author-email: support@lognexis.online
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: FastAPI
Classifier: Framework :: Flask
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: requests
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# LogNexis Python SDK

The official Python tracking SDK for **LogNexis** — the lightweight, real-time API monitoring, analytics, and observability platform.

**Website:** [https://lognexis.online](https://lognexis.online)  
**Documentation:** [https://lognexis.online/docs](https://lognexis.online/docs)

## What it does
Automatically capture API request logs, HTTP errors, latency metrics, and real-world performance without blocking your application threads. Includes drop-in middlewares for FastAPI and Flask!

## Installation

```bash
pip install lognexis-py
```

## Quick Start (FastAPI)

```python
from fastapi import FastAPI
from lognexis import LogNexisFastAPI

app = FastAPI()

# Add the LogNexis middleware
app.add_middleware(LogNexisFastAPI, api_key="YOUR_LOGNEXIS_API_KEY")

@app.get("/")
def read_root():
    return {"Hello": "World"}
```

## Quick Start (Flask)

```python
from flask import Flask
from lognexis import LogNexisFlask

app = Flask(__name__)

# Add the LogNexis tracking hook
LogNexisFlask(app, api_key="YOUR_LOGNEXIS_API_KEY")

@app.route("/")
def hello():
    return "Hello World!"
```

## Quick Start (Django)

1. Add your API key to `settings.py`:
```python
LOGNEXIS_API_KEY = "YOUR_LOGNEXIS_API_KEY"
```

2. Add the middleware to `MIDDLEWARE` in `settings.py`:
```python
MIDDLEWARE = [
    # ... other middleware ...
    'lognexis.LogNexisDjango',
]
```

## Quick Start (Streamlit)

Since Streamlit is not a traditional web server, you can use the base client to manually log user interactions or pipeline executions:

```python
import streamlit as st
from lognexis import LogNexisClient

client = LogNexisClient(api_key="YOUR_LOGNEXIS_API_KEY")

st.title("My GenAI App")

if st.button("Run Model"):
    # ... do work ...
    client.send_log({
        "method": "POST",
        "endpoint": "/run-model",
        "statusCode": 200,
        "latency": 450.5
    })
    st.success("Model executed!")
```

## Manual Usage

If you aren't using FastAPI/Flask or want to log background jobs:

```python
from lognexis.client import LogNexisClient

client = LogNexisClient("YOUR_LOGNEXIS_API_KEY")

client.send_log({
    "endpoint": "/custom-cron-job",
    "method": "POST",
    "statusCode": 200,
    "latency": 45.2
})
```

## How it works
This SDK uses python's built-in `threading` and the lightweight `requests` library. It operates in a completely "fire-and-forget" background thread, meaning your application will NEVER crash and your API response times will NEVER be slowed down by this SDK.
