Provides an interface for using a discord webhook as a logger.
Project description
dislog
Previously 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.
Install
Simple as:
pip install dislog
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.
from dislog import DiscordWebhookHandler
from logging import *
basicConfig(level=ERROR, handlers=[StreamHandler(), DiscordWebhookHandler("url", text_send_on_error="<@440468612365680650>")])
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.
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, text_send_on_error="<@440468612365680650>")])
error("hi")
await sleep(1) # Give it some time to run!
run(main())
Contributing
Setup
git clone https://github.com/regulad/dislog
cd dislog
pip install -e .
pre-commit install
Testing
tox
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dislog-2.2.0.tar.gz
.
File metadata
- Download URL: dislog-2.2.0.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b008383ac40ae4c8373fea7c354b974d62c2aed462ddc69f4eb64a4b8dffd86b |
|
MD5 | f5d7402427137fcd7da99de17f32c2d9 |
|
BLAKE2b-256 | c30231b58b71c1ef9339e6da5781ea0d413ad1898fa289d018a3015fac895443 |
Provenance
File details
Details for the file dislog-2.2.0-py3-none-any.whl
.
File metadata
- Download URL: dislog-2.2.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b147067ed192d9a152c27d4f80b5d5479583b2cafa08b358aa8efdeaaf685af0 |
|
MD5 | c91908902da1488cc70d239786469a94 |
|
BLAKE2b-256 | 67fff354ed9b10682cd08fb53f8d30ee8b2872147a0b2eb7fb6e64c1d6c715da |