format message

This commit is contained in:
joseph le 2023-09-07 14:29:37 +07:00
parent 607c90735a
commit c358da1514
3 changed files with 30 additions and 17 deletions

View File

@ -18,4 +18,9 @@ invalid |IOSXE_RP_NV-3-NV_ACCESS_FAIL|IOSXE_RP_NV-3- shj
invalid |IOSXE_RP_NV-3-NV_ACCESS_FAIL|IOSXE_RP_NV-3- shj invalid |IOSXE_RP_NV-3-NV_ACCESS_FAIL|IOSXE_RP_NV-3- shj
invalid |IOSXE_RP_NV-3-NV_ACCESS_FAIL|IOSXE_RP_NV-3- shj pak_debug_init sdh invalid |IOSXE_RP_NV-3-NV_ACCESS_FAIL|IOSXE_RP_NV-3- shj pak_debug_init sdh
abc abc
123 123 PVDM3- hui 800G2-POE-2
anfasll ak shflks as klhfalk la EHWIC- fsjklfjkl
anfasll ak shflks as klhfalk la EHWIC- fsjklfjkl
anfasll ak shflks as klhfalk la EHWIC- fsjklfjkl
123 PVDM3- hui 800G2-POE-2
123 PVDM3- hui 800G2-POE-2

View File

@ -79,7 +79,7 @@ export async function runtimeCheckLogs(folderPath) {
const filePath = `${folderPath}/${fileName}`; const filePath = `${folderPath}/${fileName}`;
const scan = fs.watchFile( const scan = fs.watchFile(
filePath, filePath,
{ interval: 300000 }, { interval: 5000 },
async (eventType) => { async (eventType) => {
//check special item, extra RAM, error in log //check special item, extra RAM, error in log
let lines = []; let lines = [];
@ -98,6 +98,11 @@ export async function runtimeCheckLogs(folderPath) {
.filter((i) => i.$original.key === "EXCLUDE_ERR") .filter((i) => i.$original.key === "EXCLUDE_ERR")
.map((obj) => obj.$original.value); .map((obj) => obj.$original.value);
let listExtraItem = allValue
.filter((i) => i.$original.key === "MODEL_SPECIAL")
.map((obj) => obj.$original.value);
console.log(listExtraItem)
content.map((line, index) => { content.map((line, index) => {
listKeyValues listKeyValues
.map((obj) => obj.$original.value) .map((obj) => obj.$original.value)
@ -160,7 +165,7 @@ export async function runtimeCheckLogs(folderPath) {
let listReport = await getListLineByItem(logsDetect[0]); let listReport = await getListLineByItem(logsDetect[0]);
let content = let content =
"| |Last updated at | Item/error | Line | Report \n|---|:---:|:---:|:---|:-----------:\n"; "| |Last updated at | Item/error | Line | Report \n|---|:---:|:---|:---|:-----------:\n";
let spoiler = ""; let spoiler = "";
// let file = await fs // let file = await fs
// .readFileSync(filePath) // .readFileSync(filePath)
@ -218,6 +223,9 @@ export async function runtimeCheckLogs(folderPath) {
// spoiler = spoiler + "\n```\n\n"; // spoiler = spoiler + "\n```\n\n";
// } else { // } else {
listReport.map((log, index) => { listReport.map((log, index) => {
let item = listExtraItem.includes(log.detected_content)
? ":medal: **" + log.detected_content+"**"
: ":small_orange_diamond: "+log.detected_content;
content = content =
content + content +
"|" + "|" +
@ -225,7 +233,7 @@ export async function runtimeCheckLogs(folderPath) {
"|**" + "|**" +
moment(log.created_at).format("HH:mm - DD/MM") + moment(log.created_at).format("HH:mm - DD/MM") +
"**|" + "**|" +
log.detected_content + item +
"|" + "|" +
log.line.sort((a, b) => a - b).join(", ") + log.line.sort((a, b) => a - b).join(", ") +
// "|" + // "|" +
@ -248,17 +256,17 @@ export async function runtimeCheckLogs(folderPath) {
spoiler spoiler
); );
sendMessToZulip( // sendMessToZulip(
"stream", // "stream",
"AUS_VN_Test", // "AUS_VN_Test",
"Test Log Alerts", // "Test Log Alerts",
":warning: :warning: **" + // ":warning: :warning: **" +
fileName + // fileName +
"**\n\n" + // "**\n\n" +
content + // content +
"\n\n" + // "\n\n" +
spoiler // spoiler
); // );
// }, 3000); // }, 3000);
} }
}, 3000); }, 3000);

View File

@ -1,5 +1,5 @@
const API = "https://logs.danielvu.com/api"; // const API = "https://logs.danielvu.com/api";
// const API = "http://localhost:3333/api"; const API = "http://localhost:3333/api";
export const getKeyValues = API + "/getKeyValue"; export const getKeyValues = API + "/getKeyValue";
export const deleteValue = API + "/deleteValue"; export const deleteValue = API + "/deleteValue";
export const addKeyValue = API + "/addValue"; export const addKeyValue = API + "/addValue";