aboutsummaryrefslogtreecommitdiffstats
path: root/bot/bot.py
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-03-28 16:33:20 +0100
committerGravatar kwzrd <[email protected]>2020-03-28 16:35:36 +0100
commit5feabe642ed5b685c7aa9515bc70ff4ff8b278bc (patch)
tree34643f1aad8fbd19f045bcaeffda897d58661599 /bot/bot.py
parentMerge master: sentry sdk, updated contributing docs (diff)
Deseasonify: log in `add_cog` rather than in each `setup`
The previous system required each extension's `setup` func to log that the cog was loaded. This leads to inconsistent messages all trying to convey the same thing, variable logger names in the output file are difficult to read, and several extensions were not logging at all. By logging directly in the `add_cog` method, we reduce code repetition, ensure consistent format, and remove the responsibility to remember that a log should be made.
Diffstat (limited to 'bot/bot.py')
-rw-r--r--bot/bot.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/bot/bot.py b/bot/bot.py
index 47d63de9..3e20e3ab 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -33,6 +33,15 @@ class SeasonalBot(commands.Bot):
connector=TCPConnector(resolver=AsyncResolver(), family=socket.AF_INET)
)
+ def add_cog(self, cog: commands.Cog) -> None:
+ """
+ Delegate to super to register `cog`.
+
+ This only serves to make the info log, so that extensions don't have to.
+ """
+ super().add_cog(cog)
+ log.info(f"Cog loaded: {cog.qualified_name}")
+
async def send_log(self, title: str, details: str = None, *, icon: str = None) -> None:
"""Send an embed message to the devlog channel."""
devlog = self.get_channel(Channels.devlog)