balena-cli/build/utils/logger.js

61 lines
1.7 KiB
JavaScript
Raw Normal View History

// Generated by CoffeeScript 1.12.6
var Logger, eol;
eol = require('os').EOL;
module.exports = Logger = (function() {
function Logger() {
var StreamLogger, _, colors, logger;
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]'));
this.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(this.streams, function(stream, key) {
if (key !== 'debug') {
return stream.pipe(process.stdout);
} else {
if (process.env.DEBUG != null) {
return stream.pipe(process.stdout);
}
}
});
}
Logger.prototype.logInfo = function(msg) {
return this.streams.info.write(msg + eol);
};
Logger.prototype.logDebug = function(msg) {
return this.streams.debug.write(msg + eol);
};
Logger.prototype.logSuccess = function(msg) {
return this.streams.success.write(msg + eol);
};
Logger.prototype.logWarn = function(msg) {
return this.streams.warn.write(msg + eol);
};
Logger.prototype.logError = function(msg) {
return this.streams.error.write(msg + eol);
};
return Logger;
})();