异步优化写入备份
This commit is contained in:
		
							
								
								
									
										25
									
								
								utils/log.py
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								utils/log.py
									
									
									
									
									
								
							| @@ -2,5 +2,30 @@ import logging | ||||
|  | ||||
|  | ||||
| class Logger: | ||||
|     __instance = None | ||||
|  | ||||
|     def __new__(cls, *args, **kwargs): | ||||
|         if cls.__instance is None: | ||||
|             cls.__instance = object.__new__(cls) | ||||
|         return cls.__instance | ||||
|  | ||||
|     def __init__(self, name): | ||||
|         self.logger = logging.getLogger(name) | ||||
|         logging.basicConfig( | ||||
|             level=logging.DEBUG, | ||||
|             format="%(asctime)s %(message)s", | ||||
|             datefmt="%Y-%m-%d %H:%M:%S", | ||||
|         ) | ||||
|         print(f"Logger initialized for {name}") | ||||
|  | ||||
|     def debug(self, msg): | ||||
|         self.logger.debug(msg) | ||||
|  | ||||
|     def info(self, msg): | ||||
|         self.logger.info(msg) | ||||
|  | ||||
|     def warning(self, msg): | ||||
|         self.logger.warning(msg) | ||||
|  | ||||
|     def error(self, msg): | ||||
|         self.logger.error(msg) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user