(self, record)
| 185 | super().__init__(fmt, datefmt='%H:%M:%S') |
| 186 | |
| 187 | def format(self, record): |
| 188 | # 创建record的副本,避免修改原始record影响其他处理器 |
| 189 | if self.use_colors: |
| 190 | # 复制record以避免修改原始对象 |
| 191 | import copy |
| 192 | record_copy = copy.copy(record) |
| 193 | levelname = record_copy.levelname |
| 194 | if levelname in self.COLORS: |
| 195 | record_copy.levelname = f"{self.COLORS[levelname]}{levelname}{self.RESET}" |
| 196 | return super().format(record_copy) |
| 197 | else: |
| 198 | return super().format(record) |
| 199 | |
| 200 | |
| 201 | class LoggingConfig: |
no outgoing calls