feat(aurora): log how many errors occured in the handle_expiry task
This commit is contained in:
parent
b91946abeb
commit
1c941462df
1 changed files with 8 additions and 2 deletions
|
@ -1114,6 +1114,7 @@ class Aurora(commands.Cog):
|
|||
global_addrole_num = 0
|
||||
global_removerole_num = 0
|
||||
global_other_num = 0
|
||||
global_err_num = 0
|
||||
|
||||
guilds: list[discord.Guild] = self.bot.guilds
|
||||
for guild in guilds:
|
||||
|
@ -1127,6 +1128,7 @@ class Aurora(commands.Cog):
|
|||
removerole_num = 0
|
||||
addrole_num = 0
|
||||
other_num = 0
|
||||
error_num = 0
|
||||
for moderation in moderations:
|
||||
try:
|
||||
num = await moderation.type.expiry_handler(moderation)
|
||||
|
@ -1135,6 +1137,7 @@ class Aurora(commands.Cog):
|
|||
continue
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
logger.exception("Expiry handler failed for moderation %s with the type %s", moderation.id, moderation.type.key, exc_info=e)
|
||||
error_num += 1
|
||||
continue
|
||||
match moderation.type.key:
|
||||
case "tempban":
|
||||
|
@ -1151,10 +1154,11 @@ class Aurora(commands.Cog):
|
|||
|
||||
per_guild_completion_time = (time.time() - time_per_guild) * 1000
|
||||
logger.debug(
|
||||
"Completed expiry loop for %s (%s) in %sms with %s users unbanned, %s roles added, and %s roles removed (%s other cases expired)",
|
||||
"Completed expiry loop for %s (%s) in %sms with %s errors, %s users unbanned, %s roles added, and %s roles removed (%s other cases expired)",
|
||||
guild.name,
|
||||
guild.id,
|
||||
f"{per_guild_completion_time:.6f}",
|
||||
error_num,
|
||||
unban_num,
|
||||
addrole_num,
|
||||
removerole_num,
|
||||
|
@ -1164,12 +1168,14 @@ class Aurora(commands.Cog):
|
|||
global_addrole_num = global_addrole_num + addrole_num
|
||||
global_removerole_num = global_removerole_num + removerole_num
|
||||
global_other_num = global_other_num + other_num
|
||||
global_err_num = global_err_num + error_num
|
||||
|
||||
|
||||
completion_time = (time.time() - current_time) * 1000
|
||||
logger.debug(
|
||||
"Completed expiry loop in %sms with %s users unbanned, %s roles added, and %s roles removed (%s other cases expired)",
|
||||
"Completed expiry loop in %sms with %s errors, %s users unbanned, %s roles added, and %s roles removed (%s other cases expired)",
|
||||
f"{completion_time:.6f}",
|
||||
global_err_num,
|
||||
global_unban_num,
|
||||
global_addrole_num,
|
||||
global_removerole_num,
|
||||
|
|
Loading…
Reference in a new issue