semvec/pypi-packages huggingface dataset:
logservice 0.1.10
Reusable CloudWatch log sender
License: MIT
Requires Python: >=3.9

# logservice

An async Python module for sending structured JSON logs to AWS CloudWatch Logs from any Python application, including FastAPI, Flask, background workers, and CLI tools.

---

## ðŸ“¦ Installation

Install directly from PyPI:

```bash
pip install logservice
```

## ðŸš€ Usage

```python
from fastapi import FastAPI
from logservice import AsyncCloudWatchLogService, LogEntry

app = FastAPI()

log_service = AsyncCloudWatchLogService(
    aws_access_key="...",
    aws_secret_key="...",
    region_name="us-east-1",
    log_group_name="app-logs",
    log_stream_name="login-events"
)

@app.post("/login")
async def login():
    await log_service.log(LogEntry(
        level="INFO",
        message="User logged in",
        service_name="LoginService",
        extra={"user_id": 123}
    ))
    return {"message": "Logged"}
```

---

## ðŸ”§ Development & Deployment

### Prerequisites

```bash
pip install twine build
```

### Deployment Steps

1. **Update version** in `setup.py`
2. **Clean old builds**:
   ```bash
   rm -rf dist/ build/ *.egg-info/
   ```
3. **Build package**:
   ```bash
   python setup.py sdist bdist_wheel
   ```
4. **Upload to PyPI**:
   ```bash
   python -m twine upload dist/*
   ```

### Quick Deploy Script

```bash
# Clean, build, and deploy
rm -rf dist/ build/ *.egg-info/
python setup.py sdist bdist_wheel
twine upload dist/*
```