mirror of https://github.com/embarklabs/embark.git
Regexp support for node 8.9.4+
Changed the log regexp to remove named capture groups as this is only supported in 10.3+.
This commit is contained in:
parent
fd142ac2e6
commit
7690418bb1
|
@ -4,7 +4,7 @@ const date = require('date-and-time');
|
||||||
const constants = require('../constants');
|
const constants = require('../constants');
|
||||||
|
|
||||||
const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss:SSS';
|
const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss:SSS';
|
||||||
// const LOG_REGEX = /\[(?<date>\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d:\d\d\d)\] (?:\[(?<logLevel>\w*)\]:?)?\s?\s?(?<msg>.*)/gmi;
|
const LOG_REGEX = new RegExp(/\[(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d:\d\d\d)\] (?:\[(\w*)\]:?)?\s?\s?(.*)/gmi);
|
||||||
|
|
||||||
class Logger {
|
class Logger {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
|
@ -38,21 +38,21 @@ class Logger {
|
||||||
let matches;
|
let matches;
|
||||||
let logs = [];
|
let logs = [];
|
||||||
const logFile = fs.readFileSync(this.logFile, 'utf8');
|
const logFile = fs.readFileSync(this.logFile, 'utf8');
|
||||||
//while ((matches = LOG_REGEX.exec(logFile)) !== null) {
|
while ((matches = LOG_REGEX.exec(logFile)) !== null) {
|
||||||
// // This is necessary to avoid infinite loops with zero-width matches
|
// This is necessary to avoid infinite loops with zero-width matches
|
||||||
// if (matches.index === LOG_REGEX.lastIndex) {
|
if (matches.index === LOG_REGEX.lastIndex) {
|
||||||
// LOG_REGEX.lastIndex++;
|
LOG_REGEX.lastIndex++;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (matches && matches.groups) {
|
if (matches && matches.length) {
|
||||||
// logs.push({
|
logs.push({
|
||||||
// msg: [matches.groups.msg],
|
msg: [matches[3]],
|
||||||
// logLevel: matches.groups.logLevel,
|
logLevel: matches[2],
|
||||||
// name: 'embark',
|
name: 'embark',
|
||||||
// timestamp: date.parse(matches.groups.date, DATE_FORMAT).getTime()
|
timestamp: date.parse(matches[1], DATE_FORMAT).getTime()
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
// if 'limit' is specified, get log lines from the end of the log file
|
// if 'limit' is specified, get log lines from the end of the log file
|
||||||
if(limit && limit > 0 && logs.length > limit){
|
if(limit && limit > 0 && logs.length > limit){
|
||||||
|
|
Loading…
Reference in New Issue