balena-cli/build/utils/logging.js
Cameron Diver f50ae65560
Add cloud-builder builder output parity to build and deploy
Change-type: minor
Signed-off-by: Cameron Diver <cameron@resin.io>
2017-04-25 13:13:11 +01:00

51 lines
1.4 KiB
JavaScript

// Generated by CoffeeScript 1.12.5
var eol;
eol = require('os').EOL;
exports.getLogStreams = function() {
var StreamLogger, _, colors, logger, streams;
StreamLogger = require('resin-stream-logger').StreamLogger;
colors = require('colors');
_ = require('lodash');
logger = new StreamLogger();
logger.addPrefix('build', colors.blue('[Build]'));
logger.addPrefix('info', colors.cyan('[Info]'));
logger.addPrefix('debug', colors.magenta('[Debug]'));
logger.addPrefix('success', colors.green('[Success]'));
logger.addPrefix('warn', colors.yellow('[Warn]'));
streams = {
build: logger.createLogStream('build'),
info: logger.createLogStream('info'),
debug: logger.createLogStream('debug'),
success: logger.createLogStream('success'),
warn: logger.createLogStream('warn')
};
_.mapKeys(streams, function(stream, key) {
if (key !== 'debug') {
return stream.pipe(process.stdout);
} else {
if (process.env.DEBUG != null) {
return stream.pipe(process.stdout);
}
}
});
return streams;
};
exports.logInfo = function(logStreams, msg) {
return logStreams.info.write(msg + eol);
};
exports.logDebug = function(logStreams, msg) {
return logStreams.debug.write(msg + eol);
};
exports.logSuccess = function(logStreams, msg) {
return logStreams.success.write(msg + eol);
};
exports.logWarn = function(logStreams, msg) {
return logStreams.warn.write(msg + eol);
};