change routes
This commit is contained in:
parent
b1b291cc16
commit
065425b0d4
|
|
@ -6,7 +6,7 @@ import LogReport from "App/Models/LogReport";
|
|||
|
||||
// export default class loggerAPI {
|
||||
export function runtimeCheckLogs(folderPath) {
|
||||
console.log(folderPath)
|
||||
console.log(folderPath);
|
||||
try {
|
||||
let fileList = [];
|
||||
let fileList_old = [];
|
||||
|
|
@ -21,7 +21,10 @@ export function runtimeCheckLogs(folderPath) {
|
|||
const stats = fs.statSync(filePath);
|
||||
|
||||
//scan file today
|
||||
if (dateNow !== moment(stats.mtime).format("YYYY/MM/DD") || file.search("log.")!==-1) {
|
||||
if (
|
||||
dateNow !== moment(stats.mtime).format("YYYY/MM/DD") ||
|
||||
file.search("log.") !== -1
|
||||
) {
|
||||
fileList = fileList.filter((i) => i !== file);
|
||||
}
|
||||
});
|
||||
|
|
@ -34,7 +37,12 @@ export function runtimeCheckLogs(folderPath) {
|
|||
folderWatcher.on("add", async (filePath) => {
|
||||
console.log(`New file added: ${filePath}`);
|
||||
//import log new file
|
||||
await LogDetectFile.firstOrCreate({file_name:filePath.split("/")[filePath.split("/").length -1]},{file_name:filePath.split("/")[filePath.split("/").length -1]})
|
||||
if (filePath.search("log.") !== -1) {
|
||||
await LogDetectFile.firstOrCreate(
|
||||
{ file_name: filePath.split("/")[filePath.split("/").length - 1] },
|
||||
{ file_name: filePath.split("/")[filePath.split("/").length - 1] }
|
||||
);
|
||||
}
|
||||
// updateFile;
|
||||
fileList_old = fileList;
|
||||
updateFileList();
|
||||
|
|
@ -63,12 +71,12 @@ export function runtimeCheckLogs(folderPath) {
|
|||
//check special item, extra RAM, error in log
|
||||
|
||||
//true: import log to log_report table, send report to Zulip
|
||||
const log = await LogDetectFile.findBy('file_name', fileName)
|
||||
const log = await LogDetectFile.findBy("file_name", fileName);
|
||||
await LogReport.create({
|
||||
detected_content: 'virk',
|
||||
detected_content: "virk",
|
||||
line: 123,
|
||||
id_file: log?.id_ldf
|
||||
})
|
||||
id_file: log?.id_ldf,
|
||||
});
|
||||
//false: next
|
||||
console.log(`${fileName} has changed (${eventType})`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue