mirror of
https://github.com/LukeHagar/VA-Log-Parser.git
synced 2025-12-06 12:57:45 +00:00
Complete Rewrite
Adjusted functionality to account for significantly larger files Better organizational Structure Added Progress Bars, added support for multiple concurrent files at once Adjusted flow so logs are parsed and sorted as lines are read and identified, this should improve performance, reliability, and error reporting.
This commit is contained in:
45
commands/parseMultipleLogFiles.js
Normal file
45
commands/parseMultipleLogFiles.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import fs from "fs";
|
||||
import linebyline from "linebyline";
|
||||
import ora from "ora";
|
||||
import cliProgress from "cli-progress";
|
||||
import sortLog from "./sortLog.js";
|
||||
|
||||
const spinner = ora();
|
||||
|
||||
let files;
|
||||
|
||||
// create new container
|
||||
const multibar = new cliProgress.MultiBar({
|
||||
format: "{duration}sec | {bar} {percentage}% | {value}/{total} Bytes",
|
||||
barCompleteChar: "\u2588",
|
||||
barIncompleteChar: "\u2591",
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
});
|
||||
|
||||
async function startParse(file) {
|
||||
const rl = linebyline(file.file);
|
||||
rl.on("line", function (line, lineCount, byteCount) {
|
||||
file.bar.update(byteCount);
|
||||
sortLog(line);
|
||||
});
|
||||
rl.on("end", function (line, lineCount, byteCount) {
|
||||
file.bar.update(file.stats.size);
|
||||
});
|
||||
}
|
||||
|
||||
export default function parseMultipleLogFiles(logFiles) {
|
||||
spinner.succeed(`Parsing Log Files: ${logFiles}`);
|
||||
files = logFiles.map((file, index) => {
|
||||
let stats = fs.statSync(file);
|
||||
return {
|
||||
file,
|
||||
stats,
|
||||
bar: multibar.create(stats.size, 0),
|
||||
index,
|
||||
};
|
||||
});
|
||||
files.forEach((file) => {
|
||||
startParse(file);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user