|
3 | 3 | from logging.handlers import RotatingFileHandler |
4 | 4 | import os.path |
5 | 5 | import sys |
6 | | -import re |
7 | 6 | from nxc.console import nxc_console |
8 | 7 | from nxc.paths import NXC_PATH |
9 | 8 | from termcolor import colored |
@@ -174,7 +173,7 @@ def log_console_to_file(self, text, *args, **kwargs): |
174 | 173 | self.logger.fail(f"Issue while trying to custom print handler: {e}") |
175 | 174 |
|
176 | 175 | def add_file_log(self, log_file=None): |
177 | | - file_formatter = TermEscapeCodeFormatter("%(asctime)s | %(filename)s:%(lineno)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S") |
| 176 | + file_formatter = logging.Formatter("%(asctime)s | %(filename)s:%(lineno)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S") |
178 | 177 | output_file = self.init_log_file() if log_file is None else log_file |
179 | 178 | file_creation = False |
180 | 179 |
|
@@ -206,17 +205,5 @@ def init_log_file(): |
206 | 205 | ) |
207 | 206 |
|
208 | 207 |
|
209 | | -class TermEscapeCodeFormatter(logging.Formatter): |
210 | | - """A class to strip the escape codes for logging to files""" |
211 | | - |
212 | | - def __init__(self, fmt=None, datefmt=None, style="%", validate=True): |
213 | | - super().__init__(fmt, datefmt, style, validate) |
214 | | - |
215 | | - def format(self, record): # noqa: A003 |
216 | | - escape_re = re.compile(r"\x1b\[[0-9;]*m") |
217 | | - record.msg = re.sub(escape_re, "", str(record.msg)) |
218 | | - return super().format(record) |
219 | | - |
220 | | - |
221 | 208 | # initialize the logger for all of nxc - this is imported everywhere |
222 | 209 | nxc_logger = NXCAdapter() |
0 commit comments