Metadata-Version: 2.4
Name: sift-dev-logger
Version: 2.0.0
Summary: A logging SDK for Sift Dev that supports Flask and FastAPI
Project-URL: Homepage, https://github.com/sift-dev/python-sdk/
Project-URL: Documentation, https://github.com/sift-dev/python-sdk/tree/main/sift_dev_logger/README.md
Project-URL: Repository, https://github.com/sift-dev/python-sdk.git
Author-email: Sift Dev <support@trysift.dev>
License-Expression: MIT
Keywords: dev,fastapi,flask,logging,sift
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: requests>=2.25.0
Provides-Extra: all
Requires-Dist: fastapi>=0.68.0; extra == 'all'
Requires-Dist: flask>=2.0.0; extra == 'all'
Requires-Dist: httpx>=0.24.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: build>=0.10.0; extra == 'dev'
Requires-Dist: flake8>=3.8.0; extra == 'dev'
Requires-Dist: httpx>=0.24.0; extra == 'dev'
Requires-Dist: pytest>=6.0.0; extra == 'dev'
Requires-Dist: twine>=4.0.0; extra == 'dev'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.68.0; extra == 'fastapi'
Requires-Dist: httpx>=0.24.0; extra == 'fastapi'
Provides-Extra: flask
Requires-Dist: flask>=2.0.0; extra == 'flask'
Description-Content-Type: text/markdown

# SIFT dev-logger (v2.0)

A lightweight Python logging SDK that provides structured logging for Flask and FastAPI applications. This new version uses a custom implementation without OpenTelemetry dependencies.

---

## Installation

### Using `pip`

```bash
pip install sift-dev-logger
```

**With optional Flask support:**

```bash
pip install "sift-dev-logger[flask]"
```

**With optional FastAPI support:**

```bash
pip install "sift-dev-logger[fastapi]"
```

**With all optional dependencies:**

```bash
pip install "sift-dev-logger[all]"
```

## Features

- Simple structured logging without dependencies on OpenTelemetry
- Batching of logs for better performance
- Customizable configuration through environment variables or code
- Support for Flask and FastAPI web frameworks
- Ability to send logs to a custom endpoint or fallback to console output

## Configuration

Configure the logger via environment variables:

```bash
# Required for sending logs to a custom endpoint
export SIFT_DEV_ENDPOINT="https://your-log-endpoint.com/logs"
export SIFT_DEV_API_KEY="your-api-key"

# Optional configuration
export SIFT_DEV_SERVICE_NAME="your-service-name"
export SIFT_DEV_SERVICE_INSTANCE_ID="your-instance-id"
export ENV="production"  # or development, staging, etc.
```

Or configure programmatically:

```python
from sift_dev_logger import configure, SiftDevConfig

# Configure once at application startup
configure(SiftDevConfig(
    service_name="my-service",
    service_instance_id="instance-1",
    endpoint="https://your-log-endpoint.com/logs",
    api_key="your-api-key",
    env="production",
    batch_size=10,  # Number of logs to batch before sending
    batch_delay_millis=5000  # Maximum time to wait before sending a batch
))
```

## Basic Usage

```python
from sift_dev_logger import getLogger

# Get a logger (automatically configured with SiftDevHandler)
logger = getLogger("my_module")

# Log messages with different severity levels
logger.info("This is an informational message")
logger.warning("This is a warning message")
logger.error("This is an error message")

# Log with additional context
logger.info("User logged in", extra={"user_id": "12345", "ip_address": "192.168.1.1"})

# Log with structured data
logger.info("API request completed", extra={
    "request_id": "req-abc-123",
    "duration_ms": 42,
    "status_code": 200,
    "user": {
        "id": "user-123",
        "role": "admin"
    }
})

# Make sure all logs are flushed before application exit
from sift_dev_logger import flush_logs
flush_logs()
```

---

## How to build and publish

1. **Install build tools**:

    ```bash
    pip install build
    ```

2. **Build the package**:

    ```bash
    python -m build
    ```

3. **Test the package locally**:

    ```bash
    pip install sift_dev_logger-0.1.0.tar.gz
    ```

4. **Upload to PyPI** (you'll need to create an account first):

    ```bash
    python -m twine upload dist/*
    ```

---

## Key Features

1. **Optional Dependencies**: Users can install just what they need (core, Flask, or FastAPI support).  
2. **Modern Build System**: Uses `hatchling` for a clean, modern build.  
3. **Clear Documentation**: README shows installation and basic usage.  
4. **Version Management**: Easy to update version in one place.  
5. **Development Tooling**: Development dependencies separated from runtime requirements.

---