mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-23 15:32:22 +00:00
57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
// Generated by CoffeeScript 1.12.6
|
|
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]'));
|
|
logger.addPrefix('error', colors.red('[Error]'));
|
|
streams = {
|
|
build: logger.createLogStream('build'),
|
|
info: logger.createLogStream('info'),
|
|
debug: logger.createLogStream('debug'),
|
|
success: logger.createLogStream('success'),
|
|
warn: logger.createLogStream('warn'),
|
|
error: logger.createLogStream('error')
|
|
};
|
|
_.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);
|
|
};
|
|
|
|
exports.logError = function(logStreams, msg) {
|
|
return logStreams.error.write(msg + eol);
|
|
};
|