Skip to content

Commit

Permalink
More accurate boot up time
Browse files Browse the repository at this point in the history
  • Loading branch information
joinemm committed Nov 28, 2023
1 parent a62cd24 commit 3f2e3e7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions modules/misobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(
self.extensions_loaded = False
self.redis: Redis = Redis()
self.datalama = Datalama(self)
self.boot_up_time: float
self.boot_up_time: float | None = None
self.session: aiohttp.ClientSession
self.register_hooks()

Expand All @@ -125,7 +125,8 @@ async def setup_hook(self):
logger.error(e)

await self.load_all_extensions()
self.boot_up_time = time() - self.start_time
boot_up_time = time() - self.start_time
logger.info(f"Setup hook done in {util.stringfromtime(boot_up_time)}")

def register_hooks(self):
"""Register event hooks to the bot"""
Expand Down Expand Up @@ -166,10 +167,10 @@ async def on_message(self, message: discord.Message):

async def on_ready(self):
"""Overrides built-in on_ready()"""
logger.info(
f"Boot up process completed in {util.stringfromtime(self.boot_up_time)}"
)
latencies = self.latencies
if self.boot_up_time is None:
self.boot_up_time = time() - self.start_time
logger.info(f"Connected in {util.stringfromtime(self.boot_up_time)}")
logger.info(f"Loading complete | running {len(latencies)} shards")
for shard_id, latency in latencies:
logger.info(f"Shard [{shard_id}] - HEARTBEAT {latency}s")
Expand Down

0 comments on commit 3f2e3e7

Please sign in to comment.