From b5e2a9f93cdf422df768053d155b1b4c357d975d Mon Sep 17 00:00:00 2001 From: Hammy Date: Mon, 15 Feb 2021 09:20:10 +0000 Subject: [PATCH] Refactor Code Remove newline characters for logging --- bot/winston.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bot/winston.py b/bot/winston.py index 19b8b29..a7d4335 100644 --- a/bot/winston.py +++ b/bot/winston.py @@ -54,13 +54,10 @@ class Winston: result = random.choice([True, False]) if result: random_tweet = random.choice(self.potential_tweets) - self.bot.update_status(status=random_tweet) - logger.info(f"Random Tweet Sent: '{random_tweet}'") + self.send_tweet(random_tweet) else: random_tweet_with_image = random.choice(self.potential_tweets_with_images) self.tweet_with_media(random_tweet_with_image) - logger.info( - f"Random Tweet With Image Sent:\nTweet: '{random_tweet_with_image[0]}'\nImage Filename: '{random_tweet_with_image[1]}'") def tweet_with_media(self, text_and_media): """Tweet with media + optional text""" @@ -74,7 +71,7 @@ class Winston: try: response = self.bot.upload_media(media=media) self.bot.update_status(status=text, media_ids=[response['media_id']]) - logger.info(f"Tweet Sent With Image:\nTweet: {text}\nImage Name: {filename}") + logger.info(f"Tweet Sent With Image: || Tweet: {text} || Image Name: {filename}") except TwythonError as error: print(error.msg)