implement function finished and triggered

This commit is contained in:
Nik Graf 2017-08-14 14:23:09 +02:00
parent 22b151fef6
commit b1dc0c48c6
No known key found for this signature in database
GPG Key ID: 7A97512F916175F1

View File

@ -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}`);