Skip to content

Commit 280448b

Browse files
committed
feat(afk.py): enhance logging for AFK expiration handler
Add debug logs to indicate when the AFK expiration check is skipped due to maintenance mode and when it is actively running. Log the absence of expired AFK entries for better traceability. Additionally, log when the AFK expiration handler starts, providing clarity on its execution schedule. These changes improve the observability and debugging capabilities of the AFK expiration process, making it easier to monitor and troubleshoot.
1 parent b23f9fe commit 280448b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/tux/modules/utility/afk.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,19 @@ async def handle_afk_expiration(self) -> None:
418418
"""Check AFK database at a regular interval, remove AFK from users with an entry that has expired."""
419419
# Skip AFK expiration processing during maintenance mode
420420
if self.bot.maintenance_mode:
421+
logger.debug("Skipping AFK expiration check (maintenance mode)")
421422
return
422423

424+
logger.debug("Running AFK expiration handler")
423425
for guild in self.bot.guilds:
424426
expired_entries = await self._get_expired_afk_entries(guild.id)
425427

426428
if expired_entries:
427429
logger.info(
428430
f"Processing {len(expired_entries)} expired AFK entries in {guild.name}",
429431
)
432+
else:
433+
logger.debug(f"No expired AFK entries found in {guild.name}")
430434

431435
for entry in expired_entries:
432436
# Re-check if entry still exists (could have been removed by user message)
@@ -468,6 +472,7 @@ async def handle_afk_expiration(self) -> None:
468472
async def before_handle_afk_expiration(self) -> None:
469473
"""Wait until the bot is ready."""
470474
await self.bot.wait_until_ready()
475+
logger.info("AFK expiration handler started (runs every 120 seconds)")
471476

472477
@handle_afk_expiration.error
473478
async def on_handle_afk_expiration_error(self, error: BaseException) -> None:

0 commit comments

Comments
 (0)