|
|
@@ -1,15 +1,13 @@
|
|
|
import os
|
|
|
+import re
|
|
|
|
|
|
from loguru import logger
|
|
|
|
|
|
-
|
|
|
-import re
|
|
|
-
|
|
|
-ANSI_ESCAPE_RE = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')
|
|
|
+ANSI_ESCAPE_RE = re.compile(r"\x1B\[[0-?]*[ -/]*[@-~]")
|
|
|
|
|
|
|
|
|
def _strip_ansi(line):
|
|
|
- return ANSI_ESCAPE_RE.sub('', line)
|
|
|
+ return ANSI_ESCAPE_RE.sub("", line)
|
|
|
|
|
|
|
|
|
def read_logs(log_files, max_lines, debug=False):
|
|
|
@@ -20,9 +18,11 @@ def read_logs(log_files, max_lines, debug=False):
|
|
|
logs = {}
|
|
|
for log_file in log_files:
|
|
|
try:
|
|
|
- with open(log_file, errors='replace') as f:
|
|
|
+ with open(log_file, errors="replace") as f:
|
|
|
lines = f.readlines()
|
|
|
- cleaned = [_strip_ansi(line.rstrip('\n')) for line in lines[-max_lines:]]
|
|
|
+ cleaned = [
|
|
|
+ _strip_ansi(line.rstrip("\n")) for line in lines[-max_lines:]
|
|
|
+ ]
|
|
|
logs[os.path.basename(log_file)] = cleaned
|
|
|
except FileNotFoundError:
|
|
|
logs[os.path.basename(log_file)] = ["Log file not found"]
|