Skip to main content

Forward Discord bot logs to Discord Text channel.

Project description

WIP: discordpy-logging-handler

Forward Discord bot logs to Discord Text channel.

Usage

import logging

import discord
from discordpy_logging_handler import DiscordBotHandler


LOG_TEXT_CHANNEL_ID = 1111111111111

logger = logging.getLogger(__name__)


class MyClient(discord.Client):
    async def on_ready(self):
        logger.info("Logged on as {0}!".format(self.user))

    async def on_message(self, message):
        logger.info("Message from {0.author}: {0.content}".format(message))


client = MyClient()
client.run("my token goes here")

log_channel = client.get_channel(LOG_TEXT_CHANNEL_ID)
logger.setLevel(logging.DEBUG)

handler = DiscordBotHandler(log_channel)
handler.setLevel(logging.INFO)

# add ch to logger
logger.addHandler(handler)

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

discordpy-logging-handler-0.1.0.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file discordpy-logging-handler-0.1.0.tar.gz.

File metadata

  • Download URL: discordpy-logging-handler-0.1.0.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.12 Linux/5.11.0-1028-azure

File hashes

Hashes for discordpy-logging-handler-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e448418b62e32e48379168fc49c63ebac0965148b02f826817335cae1e55f1e1
MD5 bef296716508e2d2138d6b865189af43
BLAKE2b-256 36f2708f559f9b87eadcd081686ee3e8a63de5b8b47f61fbba301d966b47ec81

See more details on using hashes here.

File details

Details for the file discordpy_logging_handler-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for discordpy_logging_handler-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec0e9272f81137e9babb5296c9f4b7a0876204083551c5eed9db4d1e8d0eaa59
MD5 76434a49c5f0f2cf18437326544d8994
BLAKE2b-256 0cec258f61f4f2120e6f41249c68c6cfba2f21d85dfb6a1b151ba1f4aae27a78

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