From 2bb43c5cc3bd809d8c4fd149620988ea09f277be Mon Sep 17 00:00:00 2001 From: ananthanandanan Date: Wed, 6 May 2020 20:05:46 +0530 Subject: [PATCH] Logging: Introduced logging method for debugging This commit fixes issue#52 --- nawab_logger.py | 2 ++ twitter_bot.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/nawab_logger.py b/nawab_logger.py index 65df04d..bb26b37 100644 --- a/nawab_logger.py +++ b/nawab_logger.py @@ -39,5 +39,7 @@ def logger(self, msg, level, logfile): log.warning(msg) elif level == 'error': log.error(msg) + elif level == 'debug': + log.debug(msg) else: print('Invalid message') diff --git a/twitter_bot.py b/twitter_bot.py index 6951d0c..091aa86 100644 --- a/twitter_bot.py +++ b/twitter_bot.py @@ -63,6 +63,7 @@ def isUserBanned(self, userName, admin_user): def isSafeKeyword(self, tweetText): ### Search if tweettext is safe if not any(word["Banwords"] == tweetText.lower() for index, word in self.data.iterrows()): + self.nw_logger.logger("\t|The keyword is safe: \n", 'debug', 'Error') return True return False @@ -75,8 +76,10 @@ def nawab_get_id(self): def nawab_check_tweet(self, tweet_id): tid = pd.read_csv(self.dirpath + 'tid_store.csv') if any(tid_store["Id"] == tweet_id for index, tid_store in tid.iterrows()): + self.nw_logger.logger("\t|No duplicate tweet spawned\n", 'debug', 'Error') return True else: + self.nw_logger.logger("\t| duplicate tweet spawned!! with id:" + tweet_id + "\n", 'debug', 'Error') return False def nawab_curate_list(self, api):