|
|
|
@ -258,25 +258,29 @@ settingsRoutes.get(
|
|
|
|
|
try {
|
|
|
|
|
fs.readFileSync(logFile)
|
|
|
|
|
.toString()
|
|
|
|
|
.split('\n')
|
|
|
|
|
.split(/(?=\n\d{4}-\d{2})/g)
|
|
|
|
|
.forEach((line) => {
|
|
|
|
|
if (!line.length) return;
|
|
|
|
|
|
|
|
|
|
const timestamp = line.match(new RegExp(/^.{24}/)) || [];
|
|
|
|
|
const level = line.match(new RegExp(/\s\[\w+\]/)) || [];
|
|
|
|
|
const label = line.match(new RegExp(/\]\[.+?\]/)) || [];
|
|
|
|
|
const message = line.match(new RegExp(/:\s([^{}]+)({.*})?/)) || [];
|
|
|
|
|
const jsonRegexp = new RegExp(
|
|
|
|
|
/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|"[^"\n]*?")+[}\]]{1}/
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const timestamp = line.match(new RegExp(/.{24}/)) || [];
|
|
|
|
|
const level = line.match(new RegExp(/(?<=.{24}\s\[).+?(?=\])/)) || [];
|
|
|
|
|
const label =
|
|
|
|
|
line.match(new RegExp(/(?<=.{24}\s\[.+\]\[).+(?=\])/)) || [];
|
|
|
|
|
const message =
|
|
|
|
|
line.match(new RegExp(/(?<=\[.+\]:\s)[\s\S][^\r]+/)) || [];
|
|
|
|
|
const data = message[0].match(jsonRegexp) || [];
|
|
|
|
|
|
|
|
|
|
if (level.length && filter.includes(level[0].slice(2, -1))) {
|
|
|
|
|
if (level.length && filter.includes(level[0])) {
|
|
|
|
|
logs.push({
|
|
|
|
|
timestamp: timestamp[0],
|
|
|
|
|
level: level.length ? level[0].slice(2, -1) : '',
|
|
|
|
|
label: label.length ? label[0].slice(2, -1) : '',
|
|
|
|
|
message: message.length && message[1] ? message[1] : '',
|
|
|
|
|
data:
|
|
|
|
|
message.length && message[2]
|
|
|
|
|
? JSON.parse(message[2])
|
|
|
|
|
: undefined,
|
|
|
|
|
level: level[0],
|
|
|
|
|
label: label[0],
|
|
|
|
|
message: message[0].replace(jsonRegexp, ''),
|
|
|
|
|
data: data.length ? JSON.parse(data[0]) : undefined,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|