liuyuqi-dellpc 2 months ago
parent
commit
4a25915406
1 changed files with 7 additions and 2 deletions
  1. 7 2
      repo_sync/utils/logger.py

+ 7 - 2
repo_sync/utils/logger.py

@@ -13,10 +13,15 @@ class ColoredFormatter(logging.Formatter):
     }
     }
     def format(self, record):
     def format(self, record):
         msg = record.getMessage()
         msg = record.getMessage()
+        original_msg = record.msg
         color = self.COLOR_MAP.get(record.levelno, '')
         color = self.COLOR_MAP.get(record.levelno, '')
         msg = color + msg + Style.RESET_ALL
         msg = color + msg + Style.RESET_ALL
-        record.message = msg
-        return super().format(record)
+        record.msg = msg
+        formatted_message = super().format(record)
+        # 恢复原始消息
+        record.msg = original_msg
+        
+        return formatted_message
     
     
 # Configure logger
 # Configure logger
 logger = logging.getLogger('repo_sync')
 logger = logging.getLogger('repo_sync')