From 6a606ad3dde01cbee559c8d0a6a41abfbf3b9f48 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 27 Feb 2021 11:56:35 +0100 Subject: [PATCH] Use f strings for logging --- LogBot/logbot.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/LogBot/logbot.py b/LogBot/logbot.py index cc593ae..972cac1 100644 --- a/LogBot/logbot.py +++ b/LogBot/logbot.py @@ -69,12 +69,12 @@ class Logbot(Bot): # download file data = urllib.request.urlopen(message.url).read() if data: - self.log.info("downloading: ", message.url) + self.log.info(f"downloading: {message.url}") parsed_url = urlparse(message.url) filename = ( os.path.basename(parsed_url.path).replace(" ", "_").replace("%20", "_") ) # safe url's - self.log.info("as the file: ", filename) + self.log.info(f"as the file: {filename}") roomname = re.sub(r"@.*", "", message.room) path = os.path.join(self.output, roomname, media_type) if not os.path.isdir(path): @@ -111,7 +111,7 @@ class Logbot(Bot): db=self.db[message.room]["messages"], ) out.write(html) - self.log.info("writing to: ", log_path) + self.log.info(f"writing to: {log_path}") def _add_to_db(self, message, media_post=None): """Save new entry to database.""" @@ -163,9 +163,10 @@ class Logbot(Bot): # to debug in the terminal self.log.info("------------------") - self.log.info("message: ", message.text) - self.log.info("room: ", message.room) - self.log.info("sender: ", message.sender) + self.log.info(f"message: {message.text}") + self.log.info(f"room: {message.room}") + self.log.info(f"sender: {message.sender}") + self.log.info("------------------") # image / PDF / audio / video if message.url: @@ -186,7 +187,7 @@ class Logbot(Bot): key = str(match.replace("@delete ", "")) if key in self.db[message.room]["messages"]: - self.log.info("To be deleted:", self.db[message.room]["messages"][key]) + self.log.info(f"To be deleted: {self.db[message.room]["messages"][key]}") reply = f"This message is deleted: { self.db[message.room]['messages'][key] }" del self.db[message.room]["messages"][key] else: