Metadata-Version: 2.1
Name: dislog
Version: 2.1.0
Summary: Provides an interface for using a discord webhook as a logger.
Home-page: https://github.com/regulad/dislog
Download-URL: https://github.com/regulad/dislog/archive/refs/heads/master.zip
Author: regulad
Author-email: regulad@regulad.xyz
License: GPLv3
Keywords: requests
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Development Status :: 4 - Beta
Classifier: Typing :: Typed
Classifier: Topic :: System :: Logging
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: <4,>=3.10
Description-Content-Type: text/markdown
License-File: LICENSE

# [dislog](https://pypi.org/project/dislog/)

###### Previously [`discord-webhook-logger`](https://pypi.org/project/discord-webhook-logger/)

Provides an interface for using a Discord webhook as a logger.

Designed to abstract away webhook-specific details, such as the JSON format, and provide a simple interface for logging messages.

## Example

Using `dislog` in your projects is dead simple. It behaves like any other `logging.Handler`.

For performance reasons, it even fires off a new thread for each log message, so you don't have to worry about blocking your main thread with costly HTTP requests.

```py
from dislog import DiscordWebhookHandler
from logging import *

basicConfig(level=ERROR, handlers=[StreamHandler(), DiscordWebhookHandler("url", DEBUG)])

error("hi")
```

It also works with asynchronous code, simply pass the `run_async` keyword argument. This is optional and makes it use the event loop instead of a thread pool.

```py
from dislog import DiscordWebhookHandler
from logging import *
from asyncio import run, sleep

async def main():
    basicConfig(level=ERROR, handlers=[StreamHandler(), DiscordWebhookHandler("url", run_async=True)])
    
    error("hi")
    
    await sleep(1)  # Give it some time to run!

run(main())
```

![img.png](img.png)
