# logging_module.py import logging # Setting up logging specifically for this module def configure_logger(): # 1. Create a file handler to write logs to a specific file. file_handler = logging.FileHandler('/var/log/matrix-synapse/redlight.log') file_handler.setLevel(logging.INFO) # 2. Define the format for the logs. formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') file_handler.setFormatter(formatter) # 3. Initialize the logger for this module and set its level. logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) # 4. Attach the file handler to the logger. logger.addHandler(file_handler) # Prevent this logger's messages from being passed to the root logger or other handlers. logger.propagate = False return logger