Metadata-Version: 2.5
Name: bugsradar
Version: 3.0.0
Summary: Errors of your Python application in Telegram, Discord or Pushover: logging, uncaught exceptions and direct calls in one package.
Project-URL: Homepage, https://bugsradar.com/docs/python/
Author: Bistriy Sp. z o.o.
License-Expression: MIT
License-File: LICENSE
Keywords: alerts,bugsradar,discord,error,exception,logging,pushover,telegram
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: System :: Logging
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# BugsRadar for Python

Errors of your Python application in Telegram, Discord or Pushover: the standard `logging` module, uncaught exceptions and direct calls in one package. Python 3.9 and later, no dependencies outside the standard library.

Full documentation: https://bugsradar.com/docs/python/

You need a BugsRadar project with a channel and the project's API key: create them at https://app.bugsradar.com/.

## Install

```
pip install bugsradar
```

## Set it up

Once, at the start of the program:

```python
import os
import bugsradar

bugsradar.init(
    api_key=os.environ["BUGSRADAR_KEY"],
    environment="Production",  # optional
)
```

> **The API key is secret: use it only in code that runs on your servers.** Never put it in a desktop app you ship to others (PyInstaller, PySide or PyQt builds) or in a public repository: anyone can take the key out of them. For such apps, public keys are on the way: https://bugsradar.com/docs/#public-keys

From here on, records at `ERROR` and above from every logger and uncaught exceptions go to BugsRadar. `init` adds no handlers: your logging setup works as before. Django, Flask and Uvicorn log unhandled exceptions of requests, so `init` covers them too.

## logging

```python
logger.exception("Order %s failed", order_id)
```

The format string becomes the message template, so failures of different orders are one error with a count.

## Direct calls

```python
try:
    create_order(order_id)
except Exception as error:
    bugsradar.send_exception(error, module="Orders")
```

`send` and `send_exception` queue the event and return at once; nothing raises.

## Before the program exits

`init` registers an `atexit` hook that waits up to `shutdown_timeout` (5 s) for queued reports. In a short script you can also wait yourself:

```python
bugsradar.flush()
```

Questions: support@bistriy.com
