diff --git a/lib/plugins/run/utils/logEventGateway.js b/lib/plugins/run/utils/logEventGateway.js index 2b240a65d..b45c9deb8 100644 --- a/lib/plugins/run/utils/logEventGateway.js +++ b/lib/plugins/run/utils/logEventGateway.js @@ -35,12 +35,14 @@ const getMessage = msg => { } else if (parsedMsg.msg === 'Event received.') { const event = JSON.parse(parsedMsg.event); const text = `Event received: ${event.event}${os.EOL}`; - const ppData = colorDim(prettifyValue(event)); - return `${text}${ppData}`; - } else if (parsedMsg.msg === 'Function invoked.') { + return `${text}${colorDim(prettifyValue(event))}`; + } else if (parsedMsg.msg === 'Function triggered.') { + const event = prettifyValue(JSON.parse(parsedMsg.event)); + const text = `Function triggered: ${parsedMsg.functionId}${os.EOL}${colorDim(event)}`; + return `${text}`; + } else if (parsedMsg.msg === 'Function finished.') { const response = prettifyValue(JSON.parse(parsedMsg.response)); - const responseText = `${colorDim(response)}`; - const text = `Invoked function ${parsedMsg.functionId}${os.EOL}${responseText}`; + const text = `Function finished: ${parsedMsg.functionId}${os.EOL}${colorDim(response)}`; return `${text}`; } else if (parsedMsg.msg === 'Function invocation failed.') { const text = `Failed to invoke function ${parsedMsg.functionId}${os.EOL}`; @@ -61,10 +63,10 @@ const getMessage = msg => { }; module.exports = msg => { - const processedMsg = getMessage(msg); - if (processedMsg) { + try { + const processedMsg = getMessage(msg); log(`${prefix}${processedMsg}${os.EOL}`); - } else { + } catch (err) { // NOTE keep this here - it's a worse UX to skip messages // rather than having an unformated message logged log(`${prefix}raw output: ${colorDim(msg)}${os.EOL}`);