mirror of
https://github.com/AsgardEternal/SquadJS.git
synced 2024-09-28 17:34:25 -05:00
Fix log parser stopping line processing
This commit is contained in:
parent
238df419eb
commit
1858a6d888
@ -14,16 +14,23 @@ export default class LogParser extends EventEmitter {
|
|||||||
|
|
||||||
this.eventStore = {};
|
this.eventStore = {};
|
||||||
|
|
||||||
this.queueLine = this.queueLine.bind(this);
|
this.queue = async.queue(async (line) => {
|
||||||
this.handleLine = this.handleLine.bind(this);
|
for (const rule of rules) {
|
||||||
this.queue = async.queue(this.handleLine);
|
const match = line.match(rule.regex);
|
||||||
|
if (!match) continue;
|
||||||
|
|
||||||
|
match[1] = moment.utc(match[1], 'YYYY.MM.DD-hh.mm.ss:SSS').toDate();
|
||||||
|
match[2] = parseInt(match[2]);
|
||||||
|
rule.onMatch(match, this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
switch (options.mode || 'tail') {
|
switch (options.mode || 'tail') {
|
||||||
case 'tail':
|
case 'tail':
|
||||||
this.logReader = new TailLogReader(this.queueLine, options);
|
this.logReader = new TailLogReader(this.queue.push, options);
|
||||||
break;
|
break;
|
||||||
case 'ftp':
|
case 'ftp':
|
||||||
this.logReader = new FTPLogReader(this.queueLine, options);
|
this.logReader = new FTPLogReader(this.queue.push, options);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('Invalid mode.');
|
throw new Error('Invalid mode.');
|
||||||
@ -37,20 +44,4 @@ export default class LogParser extends EventEmitter {
|
|||||||
async unwatch() {
|
async unwatch() {
|
||||||
await this.logReader.unwatch();
|
await this.logReader.unwatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
queueLine(line) {
|
|
||||||
this.queue.push(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleLine(line) {
|
|
||||||
for (const rule of rules) {
|
|
||||||
const match = line.match(rule.regex);
|
|
||||||
if (!match) continue;
|
|
||||||
|
|
||||||
match[1] = moment.utc(match[1], 'YYYY.MM.DD-hh.mm.ss:SSS').toDate();
|
|
||||||
match[2] = parseInt(match[2]);
|
|
||||||
rule.onMatch(match, this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user