From bda3b044e4aad92221021eba199d5c1dd93b6235 Mon Sep 17 00:00:00 2001 From: bucolucas Date: Sat, 17 Aug 2024 19:32:26 -0500 Subject: [PATCH] Modify logging filter to exclude multiple strings. --- telegram_inference_bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telegram_inference_bot.py b/telegram_inference_bot.py index 64d64b1..f535faa 100644 --- a/telegram_inference_bot.py +++ b/telegram_inference_bot.py @@ -25,16 +25,16 @@ class StringFilter(logging.Filter): self.strings_to_filter = strings_to_filter def filter(self, record): - return not any(string in record.getMessage() for string in self.strings_to_filter) + return not any(s in record.getMessage() for s in self.strings_to_filter) -unwanted_strings = ['unwanted_string1', 'unwanted_string2'] # Add other strings you want to filter out here +strings_to_filter = ['unwanted_string_1', 'unwanted_string_2'] # Change these to the specific strings you want to filter out # Set up logging to console and file logging.basicConfig(level=logging.INFO, handlers=[ logging.StreamHandler(), logging.FileHandler('logs/output.log', mode='a') ]) -logging.getLogger().addFilter(StringFilter(unwanted_strings)) +logging.getLogger().addFilter(StringFilter(strings_to_filter)) # Set up Telegram bot TELEGRAM_BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN')