change runtimeCheckLog

This commit is contained in:
joseph le 2023-10-04 14:29:37 +07:00
parent 5550b21bf8
commit d8efb4487f
1 changed files with 23 additions and 15 deletions

View File

@ -87,14 +87,13 @@ export async function runtimeCheckLogs(folderPath) {
// Watch for changes in the files listed
async function watchFilesInList() {
//only check new file ---> fileList - fileList_old = new file
let listFileWatch = fileList?.filter((i) => fileList_old.includes(i) === false).map((file) => folderPath + "/" + file)
const watcher = chokidar.watch(
listFileWatch,
{
persistent: true,
interval: 300000,
}
);
let listFileWatch = fileList
?.filter((i) => fileList_old.includes(i) === false)
.map((file) => folderPath + "/" + file);
const watcher = chokidar.watch(listFileWatch, {
persistent: true,
interval: 300000,
});
watcher.setMaxListeners(200);
@ -103,6 +102,7 @@ export async function runtimeCheckLogs(folderPath) {
// async (eventType) => {
//check special item, extra RAM, error in log
const fileName = path.split("/")[path.split("/").length - 1];
// const fileName = path.split("\\")[path.split("\\").length - 1];
const filePath = path;
let lines = [];
const today = DateTime.now().toFormat("yyyy-MM-dd");
@ -166,7 +166,7 @@ export async function runtimeCheckLogs(folderPath) {
.map((obj) => obj.$original.value)
.map(async (value) => {
if (
line.search(value) !== -1 &&
line.includes(value) &&
listExcludeErr.filter((err) => line.includes(err))
.length === 0
) {
@ -201,8 +201,9 @@ export async function runtimeCheckLogs(folderPath) {
listKeyValues
.map((obj) => obj.$original.value)
.map(async (value) => {
// console.log({line:Array(line), value:Array(value)})
if (
line.search(value) !== -1 &&
line.includes(value) &&
listExcludeErr.filter((err) => line.includes(err)).length ===
0
) {
@ -274,7 +275,11 @@ export async function runtimeCheckLogs(folderPath) {
"| |Last updated at | Item/error | Line | Report \n|---|:---:|:---|:---|:-----------:\n";
let spoiler = "";
let issueFound = "";
let important = [
"Vxx",
"V00",
"(CAT3K_CAA-UNIVERSALK9-M), Version 16.9.",
];
listReport.map((log, index) => {
let item = listExtraItem.includes(log.detected_content)
? ":medal: **" + log.detected_content + "**"
@ -314,13 +319,16 @@ export async function runtimeCheckLogs(folderPath) {
")\n";
});
let icon =
important.filter((i) => content.includes(i)).length > 0
? "------------\n\n:no_entry: :no_entry:**" + fileName + "**:no_entry: :no_entry:"
: "------------\n\n:warning: :warning: **" + fileName + "**";
sendMessToZulip(
"stream",
Env.get("ZULIP_STREAM_ALERT"),
Env.get("ZULIP_TOPIC_ALERT"),
"------------\n\n:warning: :warning: **" +
fileName +
"**\n\n" +
icon +
"\n\n" +
content +
"\n\n" +
spoiler +