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