Skip to content

Commit 8dabb3d

Browse files
committed
Remove formatter that strips out escape sequence, as already done by Text.from_ansi
1 parent 9d558d9 commit 8dabb3d

1 file changed

Lines changed: 1 addition & 14 deletions

File tree

nxc/logger.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from logging.handlers import RotatingFileHandler
44
import os.path
55
import sys
6-
import re
76
from nxc.console import nxc_console
87
from nxc.paths import NXC_PATH
98
from termcolor import colored
@@ -174,7 +173,7 @@ def log_console_to_file(self, text, *args, **kwargs):
174173
self.logger.fail(f"Issue while trying to custom print handler: {e}")
175174

176175
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")
178177
output_file = self.init_log_file() if log_file is None else log_file
179178
file_creation = False
180179

@@ -206,17 +205,5 @@ def init_log_file():
206205
)
207206

208207

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-
221208
# initialize the logger for all of nxc - this is imported everywhere
222209
nxc_logger = NXCAdapter()

0 commit comments

Comments
 (0)