Skip to main content

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


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 details)

Uploaded Source

Built Distribution

loghooks-0.2.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file loghooks-0.2.0.tar.gz.

File metadata

  • Download URL: loghooks-0.2.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/54.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for loghooks-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a17fc00061a25d10961814941385955f2c31fa415a3a8165f778654a241350ed
MD5 a125666f34a0b8d2e255277a3bce95ce
BLAKE2b-256 bd189c68c6caba9182a69f57302f4ed226907bac17048a867f1bddec7a5742cb

See more details on using hashes here.

File details

Details for the file loghooks-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: loghooks-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/54.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for loghooks-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7fd30ecb3735adc1128411a2cec16ec85e96c6561660f0899a7b90a3fb13e3e
MD5 ca6b0c5b9bada56ff659ceee6eb33d6a
BLAKE2b-256 98e57436a4b2618beacd02dc951272c03a522bf8b6ce269f184e057d0c563141

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page