update regex catch special version
This commit is contained in:
parent
6022621b44
commit
b1864b02a8
|
|
@ -1,15 +1,14 @@
|
|||
import Env from "@ioc:Adonis/Core/Env";
|
||||
import fs from "fs";
|
||||
import chokidar from "chokidar";
|
||||
import moment from "moment";
|
||||
import KeyValue from "App/Models/KeyValue";
|
||||
import LogDetectFile from "App/Models/LogDetectFile";
|
||||
import LogReport from "App/Models/LogReport";
|
||||
import KeyValue from "App/Models/KeyValue";
|
||||
import Database from "@ioc:Adonis/Lucid/Database";
|
||||
import { sendMessToZulip } from "./sendMessToZulip";
|
||||
import { getListLineByItem } from "./getListLineByItem";
|
||||
import { checkIndexSN } from "./checkIndexSN";
|
||||
import chokidar from "chokidar";
|
||||
import fs from "fs";
|
||||
import { DateTime } from "luxon";
|
||||
import moment from "moment";
|
||||
import { checkIndexSN } from "./checkIndexSN";
|
||||
import { getListLineByItem } from "./getListLineByItem";
|
||||
import { sendMessToZulip } from "./sendMessToZulip";
|
||||
export async function runtimeCheckLogs(folderPath) {
|
||||
try {
|
||||
let fileList = Array();
|
||||
|
|
@ -36,11 +35,11 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
|
||||
const checkSpecialVersion = (paragraph) => {
|
||||
try {
|
||||
const regex = /\(CAT3K_CAA-UNIVERSALK9-M\), Version 16\.9\.[2-9]/;
|
||||
const regex = /\(CAT[1-9]K.*Version 16\.9\.[2-9]/;
|
||||
const regex1 =
|
||||
/\(CAT3K_CAA-UNIVERSALK9-M\), Version 1[7-9]\.[0-9]\.[0-9]/;
|
||||
/\(CAT[1-9]K.*Version 1[7-9]\.[0-9]\.[0-9]/;
|
||||
const regex2 =
|
||||
/\(CAT3K_CAA-UNIVERSALK9-M\), Version [2-9][0-9]\.[0-9]\.[0-9]/;
|
||||
/\(CAT[1-9]K.*Version [2-9][0-9]\.[0-9]\.[0-9]/;
|
||||
// Use the regular expression to find the match
|
||||
const match = paragraph.match(regex);
|
||||
const match1 = paragraph.match(regex1);
|
||||
|
|
@ -73,9 +72,9 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
if (
|
||||
filePath?.split(".")[filePath.split(".").length - 1] === "log" &&
|
||||
filePath.split("/")[filePath.split("/").length - 1]?.split("-")[0] ===
|
||||
//localhost
|
||||
// filePath.split("\\")[filePath.split("\\").length - 1]?.split("-")[0] ===
|
||||
moment(Date.now()).format("YYYYMMDD").toString()
|
||||
//localhost
|
||||
// filePath.split("\\")[filePath.split("\\").length - 1]?.split("-")[0] ===
|
||||
moment(Date.now()).format("YYYYMMDD").toString()
|
||||
) {
|
||||
//add information file to database
|
||||
console.log("New file added: ", filePath);
|
||||
|
|
@ -218,7 +217,7 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
if (
|
||||
checkSpecialVersion(line) !== "" &&
|
||||
listExcludeErr.filter((err) => line.includes(err)).length ===
|
||||
0
|
||||
0
|
||||
) {
|
||||
let checkVersion = checkSpecialVersion(line);
|
||||
let log = allFile?.filter(
|
||||
|
|
@ -255,7 +254,7 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
listKeyValues
|
||||
.map((obj) => obj.$original.value)
|
||||
.map(async (value) => {
|
||||
|
||||
|
||||
if (
|
||||
line.includes(value) &&
|
||||
listExcludeErr.filter((err) => line.includes(err))
|
||||
|
|
@ -334,10 +333,10 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
} else {
|
||||
console.log(
|
||||
fileName +
|
||||
"has changed(" +
|
||||
contentFile.length +
|
||||
") ---SOS---" +
|
||||
lines.length
|
||||
"has changed(" +
|
||||
contentFile.length +
|
||||
") ---SOS---" +
|
||||
lines.length
|
||||
);
|
||||
let allReport_new = await LogReport.query().whereRaw(
|
||||
`DATE(created_at) = ?`,
|
||||
|
|
@ -351,7 +350,7 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
let logsDetect = allReport_new?.filter(
|
||||
(i) => i.$original.id_file === fileDetect?.id_ldf
|
||||
);
|
||||
|
||||
|
||||
//Get all report newest
|
||||
let listReport = await getListLineByItem(
|
||||
logsDetect
|
||||
|
|
@ -382,12 +381,12 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
contentFile[line - 1]?.replace(
|
||||
log.detected_content,
|
||||
"[" +
|
||||
log.detected_content +
|
||||
"](https://logs.danielvu.com/logs/" +
|
||||
fileName +
|
||||
"#" +
|
||||
line +
|
||||
")"
|
||||
log.detected_content +
|
||||
"](https://logs.danielvu.com/logs/" +
|
||||
fileName +
|
||||
"#" +
|
||||
line +
|
||||
")"
|
||||
);
|
||||
});
|
||||
content =
|
||||
|
|
@ -410,20 +409,20 @@ export async function runtimeCheckLogs(folderPath) {
|
|||
let icon =
|
||||
important.filter((i) => content.includes(i)).length > 0
|
||||
? "------------\n\n:no_entry: :no_entry:**" +
|
||||
fileName +
|
||||
"**: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"),
|
||||
icon +
|
||||
"\n\n" +
|
||||
content +
|
||||
"\n\n" +
|
||||
spoiler +
|
||||
"\n\n***Issue found:***\n" +
|
||||
issueFound
|
||||
"\n\n" +
|
||||
content +
|
||||
"\n\n" +
|
||||
spoiler +
|
||||
"\n\n***Issue found:***\n" +
|
||||
issueFound
|
||||
);
|
||||
}
|
||||
}, 3000);
|
||||
|
|
|
|||
Loading…
Reference in New Issue