refactor(bot): ♻️ Replace % with , in logging calls.
This commit is contained in:
+4
-4
@@ -24,7 +24,7 @@ from payphone.core import (
|
||||
formatting,
|
||||
help_command,
|
||||
config,
|
||||
logging
|
||||
logging,
|
||||
)
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class Payphone(commands.AutoShardedBot):
|
||||
|
||||
await self.redis.ping()
|
||||
|
||||
self.log.info("Ready! Logged in as %s." % self.user.display_name)
|
||||
self.log.info("Ready! Logged in as %s.", self.user.display_name)
|
||||
|
||||
async def on_shard_ready(self, shard_id: int) -> None:
|
||||
"""Sets the activity for the shard.
|
||||
@@ -101,7 +101,7 @@ class Payphone(commands.AutoShardedBot):
|
||||
shard_id=shard_id,
|
||||
)
|
||||
|
||||
self.log.info("Shard %s is ready!" % shard_id)
|
||||
self.log.info("Shard %s is ready!", shard_id)
|
||||
|
||||
async def on_shard_resumed(self, shard_id: int) -> None:
|
||||
"""Sets the activity for the shard.
|
||||
@@ -118,7 +118,7 @@ class Payphone(commands.AutoShardedBot):
|
||||
shard_id=shard_id,
|
||||
)
|
||||
|
||||
self.log.info("Shard %s was resumed!" % shard_id)
|
||||
self.log.info("Shard %s was resumed!", shard_id)
|
||||
|
||||
async def get_or_fetch_channel(
|
||||
self, channel_id: int
|
||||
|
||||
@@ -79,10 +79,10 @@ async def flush():
|
||||
except (
|
||||
asyncpg.exceptions.PostgresError,
|
||||
asyncpg.exceptions.InterfaceError,
|
||||
) as e:
|
||||
log.error(
|
||||
"[Call ID: %s] An error occured trying to flush messages for call ID. %s"
|
||||
% (call_id, e)
|
||||
):
|
||||
log.exception(
|
||||
"[Call ID: %s] An error occured trying to flush messages for call ID."
|
||||
% call_id
|
||||
)
|
||||
continue
|
||||
|
||||
@@ -96,10 +96,10 @@ async def flush():
|
||||
except (
|
||||
asyncpg.exceptions.PostgresError,
|
||||
asyncpg.exceptions.InterfaceError,
|
||||
) as e:
|
||||
log.error(
|
||||
"[Call ID: %s] An error occured trying to flush message contents. %s"
|
||||
% (call_id, e)
|
||||
):
|
||||
log.exception(
|
||||
"[Call ID: %s] An error occured trying to flush message contents."
|
||||
% call_id
|
||||
)
|
||||
continue
|
||||
|
||||
@@ -127,4 +127,4 @@ async def loop() -> None:
|
||||
await flush()
|
||||
|
||||
except (KeyboardInterrupt, asyncio.exceptions.CancelledError) as e:
|
||||
log.exception(e)
|
||||
log.exception('')
|
||||
|
||||
@@ -34,7 +34,7 @@ def shard(
|
||||
bot.shutdown = shutdown
|
||||
bot.scheduled_shutdown = scheduled_shutdown
|
||||
|
||||
log.info("Running shard %s with default loop." % shard_id)
|
||||
log.info("Running shard %s with default loop.", shard_id)
|
||||
bot.run(config.TOKEN)
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ if __name__ == "__main__":
|
||||
shutdown = manager.Value("b", False)
|
||||
scheduled_shutdown = manager.Value("b", False)
|
||||
|
||||
log.info("Starting %s shards." % shard_count)
|
||||
log.info("Starting %s shards.", shard_count)
|
||||
|
||||
ps: list[mp.Process] = [
|
||||
mp.Process(
|
||||
@@ -119,13 +119,11 @@ if __name__ == "__main__":
|
||||
for i, p in enumerate(ps):
|
||||
p.start()
|
||||
|
||||
log.info("Shard %s's process started.", i)
|
||||
log.info(
|
||||
f"Shard {i}'s process started."
|
||||
+ (
|
||||
" Waiting 5 seconds start initialize next shard..."
|
||||
"Waiting 5 seconds start initialize next shard..."
|
||||
if i != len(ps) - 1
|
||||
else " All shards were started."
|
||||
)
|
||||
else "All shards were started."
|
||||
)
|
||||
|
||||
if i != len(ps) - 1:
|
||||
@@ -144,9 +142,7 @@ if __name__ == "__main__":
|
||||
|
||||
for i in range(shard_count):
|
||||
if not ps[i].is_alive():
|
||||
log.warning(
|
||||
"Shard %s's process exited. Restarting the shard..." % s
|
||||
)
|
||||
log.warning("Shard %s's process exited. Restarting the shard...", i)
|
||||
|
||||
ps[i] = mp.Process(
|
||||
target=shard,
|
||||
@@ -161,8 +157,8 @@ if __name__ == "__main__":
|
||||
ps[i].start()
|
||||
|
||||
log.info(
|
||||
"Shard %s was restarted. Waiting 5 seconds to check next shard..."
|
||||
% i
|
||||
"Shard %s was restarted. Waiting 5 seconds to check next shard...",
|
||||
i,
|
||||
)
|
||||
time.sleep(5)
|
||||
|
||||
@@ -183,11 +179,11 @@ if __name__ == "__main__":
|
||||
log.info("A shard shut down the bot.")
|
||||
|
||||
finally:
|
||||
log.info("Terminating %s shards..." % shard_count)
|
||||
log.info("Terminating %s shards...", shard_count)
|
||||
|
||||
for i, p in enumerate(ps):
|
||||
p.terminate()
|
||||
log.info("Terminated shard %s." % i)
|
||||
log.info("Terminated shard %s.", i)
|
||||
|
||||
log.info("Stopping messages flushing process...")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user