mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
implement function finished and triggered
This commit is contained in:
parent
22b151fef6
commit
b1dc0c48c6
@ -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}`);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user