is there away to make this code not spam in the second file without interfering with any other functions? "Anomaly.log" is being spammed although "Bandit.log" is not being spammed, what am I doing wrong? import pyautogui import schedule import time import logging # Initialize a counter call_count = 0 # Example calls def logger(): logging.basicConfig(level=logging.INFO, filename="bandit.log", filemode="w", format="%(asctime)s - %(levelname)s - %(message)s") logger = logging.getLogger(__name__) logger.propagate = False handler = logging.FileHandler('anomaly.log') formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") handler.setFormatter(formatter) logger.addHandler(handler) try: location = pyautogui.locateOnScreen('1.png', confidence=0.9) if pyautogui.locateOnScreen('1.png', confidence=0.9): global call_count call_count += 1 logging.info(call_count) except pyautogui.ImageNotFoundException: pass def bandit_cycle(): try: location = pyautogui.locateOnScreen('1.png', confidence=0.9) logging.info('x1 Data found') time.sleep(1.5) except: pass # schedule for main working code schedule.every(1).seconds.do(bandit_main) # schedule for main working code schedule.every(1).seconds.do(logger) while True: schedule.run_pending() time.sleep(1) Anomaly.log 2025-02-03 14:51:19,773 - main - INFO - 1 2025-02-03 14:51:19,773 - main - INFO - 1 2025-02-03 14:51:19,773 - main - INFO - 1 2025-02-03 14:51:19,773 - main - INFO - 1 2025-02-03 14:51:57,076 - main - INFO - 2 2025-02-03 14:51:57,076 - main - INFO - 2 2025-02-03 14:51:57,076 - main - INFO - 2 2025-02-03 14:51:57,076 - main - INFO - 2 2025-02-03 14:51:57,076 - main - INFO - 2 2025-02-03 14:51:57,076 - main - INFO - 2 2025-02-03 14:51:57,076 - main - INFO - 2 2025-02-03 14:51:57,076 - main - INFO - 2 2025-02-03 14:51:57,076 - main - INFO - 2 2025-02-03 14:51:57,076 - main - INFO - 2 Bandit.log 2025-02-03 14:51:15,548 - INFO - x1 Data found 2025-02-03 14:51:19,773 - INFO - 1 2025-02-03 14:51:52,877 - INFO - x1 Data found 2025-02-03 14:51:57,076 - INFO - 2 2025-02-03 14:52:30,495 - INFO - x5 Data found** Continue reading...