| 118 | |
| 119 | # 重定向到该日志文件,同时输出到控制台 |
| 120 | class TeeOutput: |
| 121 | def __init__(self, *files): |
| 122 | self.files = files |
| 123 | |
| 124 | def write(self, data): |
| 125 | if data: |
| 126 | data = sanitize_log_message(data) |
| 127 | for f in self.files: |
| 128 | f.write(data) |
| 129 | f.flush() |
| 130 | |
| 131 | def flush(self): |
| 132 | for f in self.files: |
| 133 | f.flush() |
| 134 | |
| 135 | log_file_obj = open(temp_log_file, 'a', buffering=1) # 行缓冲 |
| 136 | sys.stdout = TeeOutput(sys.__stdout__, log_file_obj) |
no outgoing calls
no test coverage detected