Added filter to logging configuration to exclude logs containing the string 'DEBUG'

This commit is contained in:
2024-08-17 19:30:18 -05:00
parent b465f19228
commit 5f86f43637
+9 -1
View File
@@ -19,12 +19,20 @@ client = OpenAI()
GPT_4O = "gpt-4o"
GPT_4O_MINI = "gpt-4o-mini"
# Set up logging to console and file
class NoDebugFilter(logging.Filter):
def filter(self, record):
return "DEBUG" not in record.getMessage()
# Set up logging to console and file with filter
logging.basicConfig(level=logging.INFO, handlers=[
logging.StreamHandler(),
logging.FileHandler('logs/output.log', mode='a')
])
# Add filter to the handlers
for handler in logging.getLogger().handlers:
handler.addFilter(NoDebugFilter())
# Set up Telegram bot
TELEGRAM_BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN')