mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-23 15:32:22 +00:00
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
// Generated by CoffeeScript 1.12.7
|
|
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);
|
|
}
|
|
}
|
|
});
|
|
this.formatMessage = logger.formatWithPrefix.bind(logger);
|
|
}
|
|
|
|
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;
|
|
|
|
})();
|