This commit is contained in:
Daniel García Aubert 2020-07-01 10:53:04 +02:00
parent cb17bba3f5
commit afd4ad500f
2 changed files with 6 additions and 7 deletions

View File

@ -4,7 +4,7 @@ const split = require('split2');
const logCollector = require('./log-collector');
const metricsCollector = require('./metrics-collector');
const streams = [process.stdin, split(), logCollector(), metricsCollector(), process.stdout]
const streams = [process.stdin, split(), logCollector(), metricsCollector(), process.stdout];
pipeline('pipe', streams);

View File

@ -16,7 +16,7 @@ const LEVELS = {
40: 'warn',
50: 'error',
60: 'fatal'
}
};
module.exports = function logCollector () {
const stream = new Transform({
@ -58,10 +58,9 @@ module.exports = function logCollector () {
}
if (accEntry.level > entry.level) {
delete entry.level
delete entry.level;
}
let error;
if (hasProperty(accEntry, 'error') && hasProperty(entry, 'error')) {
logs.set(id, assingDeep({}, accEntry, entry, { error: accEntry.error.concat(entry.error) }));
} else {
@ -99,8 +98,8 @@ module.exports = function logCollector () {
});
return stream;
}
};
function hasProperty (obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop)
return Object.prototype.hasOwnProperty.call(obj, prop);
}