import logging import io # StringIO buffer captures logs for streaming log_buffer = io.StringIO() logger = logging.getLogger("transcription_logger") logger.setLevel(logging.DEBUG) # Log handler that writes to the StringIO buffer log_handler = logging.StreamHandler(log_buffer) log_handler.setLevel(logging.DEBUG) # Formatter for the logs formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') log_handler.setFormatter(formatter) logger.addHandler(log_handler) logger.propagate = False