Logging¶
There are two log targets: the bot one and a guild one. You, as a developer, will most likely be using the Guild logger – all the logs send to it will be contained only in the guild (and the hosting server); the Bot logs are distributed to all guilds the lemon.py instance is connected to.
The logger targets are usually defined on top of the file:
from core import logging
bot_log = logging.Bot.logger()
guild_log = logging.Guild.logger()
And to use the logger, use
try:
await action_that_throws_error()
except guilded.exceptions.HTTPException:
await guild_log(
ctx.author,
ctx.channel,
"Could not do the action.",
exception=exc,
)
Please note that because the logs may be sent to the logging channels on Guilded, they have to be awaited.