Metadata-Version: 2.4
Name: bunnylogs
Version: 0.1.6
Summary: Python logging handler for BunnyLogs
Project-URL: Homepage, https://bunnylogs.com
Project-URL: Repository, https://github.com/RubenNorgaard/bunnylogs-python
License: MIT
Keywords: bunnylogs,log handler,logging
Classifier: Development Status :: 4 - Beta
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
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: System :: Logging
Requires-Python: >=3.8
Requires-Dist: certifi
Requires-Dist: websockets>=11.0
Description-Content-Type: text/markdown

# bunnylogs

Python logging handler for [BunnyLogs](https://bunnylogs.com) — ship your logs to a live stream with three lines of code.

## Install

```bash
pip install bunnylogs
```

## Usage

```python
import logging
from bunnylogs import BunnyLogsHandler

logging.getLogger().addHandler(BunnyLogsHandler("your-uuid-here"))
```

That's it. Every log record at `WARNING` and above (or whatever level your root logger is set to) will appear in your BunnyLogs stream in real time.

### Capture a specific logger

```python
import logging
from bunnylogs import BunnyLogsHandler

handler = BunnyLogsHandler("your-uuid-here")
handler.setLevel(logging.DEBUG)

logger = logging.getLogger("myapp")
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
```

### Django — `settings.py`

```python
LOGGING = {
    "version": 1,
    "handlers": {
        "bunnylogs": {
            "class": "bunnylogs.BunnyLogsHandler",
            "uuid": "your-uuid-here",
        },
    },
    "root": {
        "handlers": ["bunnylogs"],
        "level": "WARNING",
    },
}
```

### Self-hosted deployments

```python
BunnyLogsHandler("your-uuid-here", endpoint="https://your-own-host.com")
```

## How it works

Log records are placed on an in-process queue and flushed by a daemon thread, so `emit()` is non-blocking (~microseconds on the calling thread). The background thread sends one HTTPS POST per record using only the Python standard library — no external dependencies.

On process exit the daemon thread is killed. Call `handler.close()` explicitly if you need to guarantee all queued records are flushed before shutdown.

## Parameters

| Parameter  | Default                    | Description                              |
|------------|----------------------------|------------------------------------------|
| `uuid`     | —                          | Your logspace UUID                       |
| `level`    | `logging.NOTSET`           | Minimum level to forward                 |
| `endpoint` | `https://bunnylogs.com`    | Base URL (override for self-hosted)      |
| `timeout`  | `5`                        | HTTP request timeout in seconds          |

## License

MIT
