mirror of https://github.com/embarklabs/embark.git
Fix the way messages are appended in logs
This commit is contained in:
parent
1a20b7b9ae
commit
3b45128f20
|
@ -92,11 +92,27 @@ class ProcessLauncher {
|
||||||
|
|
||||||
// Translates logs from the child process to the logger
|
// Translates logs from the child process to the logger
|
||||||
_handleLog(msg) {
|
_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();
|
const timestamp = new Date().getTime();
|
||||||
this.events.emit('process-log-' + this.name, msg.type, msg.message, this.name, timestamp);
|
|
||||||
|
processedMessages.forEach((message) => {
|
||||||
|
this.events.emit('process-log-' + this.name, msg.type, message, this.name, timestamp);
|
||||||
this.logs.push({
|
this.logs.push({
|
||||||
msg: msg.message,
|
msg: message,
|
||||||
msg_clear: msg.message.stripColors,
|
msg_clear: message.stripColors,
|
||||||
logLevel: msg.logLevel,
|
logLevel: msg.logLevel,
|
||||||
name: this.name,
|
name: this.name,
|
||||||
timestamp
|
timestamp
|
||||||
|
@ -105,9 +121,10 @@ class ProcessLauncher {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.logger[msg.type]) {
|
if (this.logger[msg.type]) {
|
||||||
return this.logger[msg.type](utils.normalizeInput(msg.message));
|
return this.logger[msg.type](utils.normalizeInput(message));
|
||||||
}
|
}
|
||||||
this.logger.debug(utils.normalizeInput(msg.message));
|
this.logger.debug(utils.normalizeInput(message));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle event calls from the child process
|
// Handle event calls from the child process
|
||||||
|
|
Loading…
Reference in New Issue