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

Uploaded Source

Built Distribution

discordpy_logging_handler-0.1.0-py3-none-any.whl (29.6 kB view hashes)

Uploaded Python 3

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