mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
33 lines
713 B
JavaScript
33 lines
713 B
JavaScript
'use strict';
|
|
|
|
const os = require('os');
|
|
const chalk = require('chalk');
|
|
|
|
const colorPrefix = chalk.hex('#bdb018');
|
|
const colorDim = chalk.hex('#777777');
|
|
const spaceSmall = ' ';
|
|
const prefix = colorPrefix(` Serverless${spaceSmall}`);
|
|
|
|
const processMessage = msg => {
|
|
if (msg.trim().length < 0) {
|
|
return false;
|
|
} else if (typeof msg === 'string') {
|
|
msg = msg.trim();
|
|
|
|
if (msg.startsWith('Error:')) {
|
|
msg = `Function error:${os.EOL}${os.EOL}${colorDim(msg)}${os.EOL}`
|
|
}
|
|
}
|
|
|
|
return msg;
|
|
};
|
|
|
|
function logLocalEmulator(message) {
|
|
message = processMessage(message);
|
|
if (message) {
|
|
process.stdout.write(`${prefix}${message}${os.EOL}`);
|
|
}
|
|
}
|
|
|
|
module.exports = logLocalEmulator;
|