A discord webhook logging library
Project description
Log Hooks
A discord webhook logging library
There are no docs as this isn't meant to be used in bots that are sharded or log a lot. Just ping moanie#6598 on discord.py for help (ID: 691406006277898302)
Example:
import discord
import logging
import aiohttp
from loghooks import WebhookHandler
client = discord.Client() # use commands.Bot if you wish. It doesn't make a difference.
handler = WebhookHandler(
webhook_url = "webhook-url",
session = aiohttp.ClientSession()
)
@client.event
async def on_ready():
print("ready")
# actual logging stuff
logger = logging.getLogger("discord")
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
handler.setLevel(logging.INFO)
client.run("Bot Token")
Using your own functions
import discord
import logging
import aiohttp
from loghooks import WebhookHandler
from logging import LogRecord
client = discord.Client() # use commands.Bot if you wish. It doesn't make a difference.
handler = WebhookHandler(
webhook_url = "webhook-url",
session = aiohttp.ClientSession()
)
@client.event
async def on_ready():
print("ready")
async def my_custom_webhook_function(log: LogRecord):
... # handle your log here
# actual logging stuff
logger = logging.getLogger("discord")
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
handler.setLevel(logging.INFO)
handler.setCustomHandle(my_custom_webhook_function)
client.run("Bot Token")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
loghooks-0.2.0.tar.gz
(3.1 kB
view hashes)