diff --git a/lib/core/processes/processLauncher.js b/lib/core/processes/processLauncher.js index dc79df329..6616e50b0 100644 --- a/lib/core/processes/processLauncher.js +++ b/lib/core/processes/processLauncher.js @@ -92,22 +92,39 @@ class ProcessLauncher { // Translates logs from the child process to the logger _handleLog(msg) { + // Sometimes messages come in with line breaks, so we need to break them up accordingly. + let processedMessages = []; + + // Ensure that `msg.message` is an array, so we process this consistently. Sometimes it + // is an Array, sometimes it is a string. + if(typeof msg.message === 'string') { + processedMessages = [msg.message]; + } else { + msg.message.forEach((message) => { + let lines = message.split("\n"); + lines.forEach((line) => { processedMessages.push(line); }); + }); + } + const timestamp = new Date().getTime(); - this.events.emit('process-log-' + this.name, msg.type, msg.message, this.name, timestamp); - this.logs.push({ - msg: msg.message, - msg_clear: msg.message.stripColors, - logLevel: msg.logLevel, - name: this.name, - timestamp + + processedMessages.forEach((message) => { + this.events.emit('process-log-' + this.name, msg.type, message, this.name, timestamp); + this.logs.push({ + msg: message, + msg_clear: message.stripColors, + logLevel: msg.logLevel, + name: this.name, + timestamp + }); + if (this.silent && msg.type !== 'error') { + return; + } + if (this.logger[msg.type]) { + return this.logger[msg.type](utils.normalizeInput(message)); + } + this.logger.debug(utils.normalizeInput(message)); }); - if (this.silent && msg.type !== 'error') { - return; - } - if (this.logger[msg.type]) { - return this.logger[msg.type](utils.normalizeInput(msg.message)); - } - this.logger.debug(utils.normalizeInput(msg.message)); } // Handle event calls from the child process