update runtimeCheckLog
This commit is contained in:
parent
21246cb20a
commit
86efd162c9
|
|
@ -1,7 +1,11 @@
|
|||
fjsfhsjkk
|
||||
sjghsjkdg
|
||||
err
|
||||
sngjksg
|
||||
fault
|
||||
fhgg45345
|
||||
trace
|
||||
WS-X68
|
||||
WS-X68
|
||||
WS-X68
|
||||
WS-X68
|
||||
WS-X68
|
||||
SM-
|
||||
SM-
|
||||
SM-
|
||||
WS-X68
|
||||
WS-X68
|
||||
WS-X68
|
||||
|
|
@ -72,7 +72,7 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
const filePath = `${folderPath}/${fileName}`;
|
||||
const scan = fs.watchFile(
|
||||
filePath,
|
||||
{ interval: 120000 },
|
||||
{ interval: 5000 },
|
||||
async (eventType) => {
|
||||
//check special item, extra RAM, error in log
|
||||
let lines = [];
|
||||
|
|
@ -85,13 +85,13 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
.map((obj) => obj.$original.value)
|
||||
.map(async (value) => {
|
||||
if (line.search(value) !== -1) {
|
||||
let keyWord = "";
|
||||
line.split(" ").map((word) => {
|
||||
if (word.toLocaleLowerCase().includes(value)) {
|
||||
keyWord = keyWord + word;
|
||||
}
|
||||
});
|
||||
if (value.length === keyWord.length) {
|
||||
// let keyWord = "";
|
||||
// line.split(" ").map((word) => {
|
||||
// if (word.toLocaleLowerCase().includes(value)) {
|
||||
// keyWord = keyWord + word;
|
||||
// }
|
||||
// });
|
||||
// if (value.length === keyWord.length) {
|
||||
const log = await LogDetectFile.findBy(
|
||||
"file_name",
|
||||
fileName
|
||||
|
|
@ -115,7 +115,7 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
});
|
||||
lines.push(index + 1);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -136,29 +136,30 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
"select * from log_reports where id_file = " +
|
||||
fileDetect?.id_ldf
|
||||
);
|
||||
let content =
|
||||
":warning: :warning: " +
|
||||
fileName +
|
||||
"\n\n| | Item/error | Line | Detected at | Report\n|---|:---:|:---:|:---:|:-----------:\n";
|
||||
|
||||
let content = "| | Item/error | Line | Detected at | Report\n|---|:---:|:---:|:---:|:-----------:\n";
|
||||
let spoiler = "";
|
||||
if (logsDetect[0].length > 10) {
|
||||
content =
|
||||
content +
|
||||
"|1|**" +
|
||||
logsDetect[0][0].detected_content +
|
||||
"**|" +
|
||||
logsDetect[0][0].line +
|
||||
"|" +
|
||||
logsDetect[0][0].created_at +
|
||||
"|[View](https://logs.danielvu.com/api/log/showLog/" +
|
||||
fileName +
|
||||
")\n|...|**...**|...|...|...\n";
|
||||
logsDetect[0]
|
||||
.slice(logsDetect[0].length - 6, logsDetect[0].length - 1)
|
||||
// content =
|
||||
// content +
|
||||
// "|1|**" +
|
||||
// logsDetect[0][0].detected_content +
|
||||
// "**|" +
|
||||
// logsDetect[0][0].line +
|
||||
// "|" +
|
||||
// logsDetect[0][0].created_at +
|
||||
// "|[View](https://logs.danielvu.com/api/log/showLog/" +
|
||||
// fileName +
|
||||
// ")\n|...|**...**|...|...|...\n";
|
||||
spoiler = spoiler + "```spoiler ..."+ (logsDetect[0].length - 5) +" more items\n" + content
|
||||
|
||||
logsDetect[0].reverse()
|
||||
.slice(0, 5)
|
||||
?.map((log, index) => {
|
||||
content =
|
||||
content +
|
||||
content +
|
||||
"|" +
|
||||
(index + 1 + logsDetect[0].length - 6) +
|
||||
(logsDetect[0].length - index) +
|
||||
"|**" +
|
||||
log.detected_content +
|
||||
"**|" +
|
||||
|
|
@ -169,12 +170,32 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
fileName +
|
||||
")\n";
|
||||
});
|
||||
|
||||
logsDetect[0]
|
||||
.slice(5, logsDetect[0].length)
|
||||
?.map((log, index) => {
|
||||
spoiler =
|
||||
spoiler +
|
||||
"|" +
|
||||
(logsDetect[0].length - index - 5) +
|
||||
"|**" +
|
||||
log.detected_content +
|
||||
"**|" +
|
||||
log.line +
|
||||
"|" +
|
||||
log.created_at +
|
||||
"|[View](https://logs.danielvu.com/api/log/showLog/" +
|
||||
fileName +
|
||||
")\n";
|
||||
});
|
||||
|
||||
spoiler = spoiler + "\n```\n\n";
|
||||
} else {
|
||||
logsDetect[0].map((log, index) => {
|
||||
logsDetect[0].reverse().map((log, index) => {
|
||||
content =
|
||||
content +
|
||||
"|" +
|
||||
(index + 1) +
|
||||
(logsDetect[0].length - index) +
|
||||
"|**" +
|
||||
log.detected_content +
|
||||
"**|" +
|
||||
|
|
@ -191,7 +212,9 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
"stream",
|
||||
"Result test - auto.nswteam.net",
|
||||
"Log Alert",
|
||||
content
|
||||
":warning: :warning: **" +
|
||||
fileName +
|
||||
"**\n\n"+content+"\n\n"+spoiler
|
||||
);
|
||||
// }, 3000);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,33 +51,29 @@ Route.get("/api/log/showLog/:name?", async ({ request, response }) => {
|
|||
let listKeyValues = await KeyValue.all();
|
||||
// console.log(listKeyValues)
|
||||
let data = content.data.split("\n");
|
||||
|
||||
console.log(data)
|
||||
data.map((line, index) => {
|
||||
// console.log(line)
|
||||
data[index] =
|
||||
"<span style='background-color:pink;'>" + (index + 1) + "</span>" + line;
|
||||
data[index] = "<span style='background-color:pink;'>" + (index + 1) + "</span>" + line;
|
||||
listKeyValues
|
||||
.map((obj) => obj.$original.value)
|
||||
.map(async (value) => {
|
||||
if (line.search(value) !== -1) {
|
||||
let keyWord = "";
|
||||
line.split(" ").map((word) => {
|
||||
if (word.toLocaleLowerCase().includes(value)) {
|
||||
keyWord = keyWord + word;
|
||||
}
|
||||
});
|
||||
|
||||
if (value.length === keyWord.length) {
|
||||
// let keyWord = "";
|
||||
// line.split(" ").map((word) => {
|
||||
// if (word.toLocaleLowerCase().includes(value)) {
|
||||
// keyWord = keyWord + word;
|
||||
// }
|
||||
// });
|
||||
|
||||
// if (value.length === keyWord.length || value.length + 1 === keyWord.length) {
|
||||
data[index] =
|
||||
"<span style='background-color:pink;'>" +
|
||||
(index + 1) +
|
||||
"</span>" +
|
||||
line.slice(0, line.search(value)) +
|
||||
data[index].slice(0, data[index].search(value)) +
|
||||
"<span style='background-color:yellow;'>" +
|
||||
value +
|
||||
"</span>" +
|
||||
line.slice(line.search(value) + value.length);
|
||||
}
|
||||
data[index].slice(data[index].search(value) + value.length);
|
||||
// }
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue