This commit is contained in:
Igor Zinkovsky 2012-05-01 16:43:56 -07:00
Родитель b8e43bde23
Коммит 7b61c5e384
1 изменённых файлов: 13 добавлений и 8 удалений

Просмотреть файл

@ -33,7 +33,7 @@ var istty1 = tty.isatty(1);
if (!process.env.AZURE_DEBUG || process.env.AZURE_DEBUG !== '1') { if (!process.env.AZURE_DEBUG || process.env.AZURE_DEBUG !== '1') {
process.on('uncaughtException', function (err) { process.on('uncaughtException', function (err) {
clearProgress(); clearProgress();
var loggedFullError = false; var loggedFullError = false;
if (err.message) { if (err.message) {
log.error(err.message); log.error(err.message);
@ -53,18 +53,17 @@ if (!process.env.AZURE_DEBUG || process.env.AZURE_DEBUG !== '1') {
} }
cli.exit('error', null, 1); cli.exit('error', null, 1);
}); });
} }
/////////////////////////// ///////////////////////////
// prepare output logger // prepare output logger
// use cli output settings by default // use cli output settings by default
log.cli(); log.cli();
log.format = function(options) { log.format = function (options) {
var transport = log['default'].transports.console; var transport = log['default'].transports.console;
if (arguments.length === 0) { if (arguments.length === 0) {
return { return {
json: transport.json, json: transport.json,
@ -73,20 +72,23 @@ log.format = function(options) {
logo: log.format.logo logo: log.format.logo
}; };
} }
if (options.json) { if (options.json) {
log.padLevels = false; log.padLevels = false;
log.stripColors = true; log.stripColors = true;
transport.json = true; transport.json = true;
transport.terse = true; transport.terse = true;
} }
if (options.terse) { if (options.terse) {
log.padLevels = false; log.padLevels = false;
transport.terse = true; transport.terse = true;
} }
if (options.level) { if (options.level) {
transport.level = options.level; transport.level = options.level;
} }
if (options.logo) { if (options.logo) {
log.format.logo = options.logo; log.format.logo = options.logo;
} }
@ -98,12 +100,13 @@ log.json = function (level, data) {
data = level; data = level;
level = 'data'; level = 'data';
} }
if (log.format().json) { if (log.format().json) {
log.log(level, typeof data, data); log.log(level, typeof data, data);
} else { } else {
var lines = eyes.inspect(data, level, { stream: false }); var lines = eyes.inspect(data, level, { stream: false });
lines.split('\n').forEach(function (line) { lines.split('\n').forEach(function (line) {
// eyes all is "cyan" by default, so this property accessor will // eyes all is "cyan" by default, so this property accessor will
// fix the entry/exit color codes of the line. it's needed because we're // fix the entry/exit color codes of the line. it's needed because we're
// splitting the eyes formatting and inserting winston formatting where it // splitting the eyes formatting and inserting winston formatting where it
// wasn't before. // wasn't before.
@ -119,6 +122,7 @@ log.table = function (level, data, transform) {
data = level; data = level;
level = 'data'; level = 'data';
} }
if (log.format().json) { if (log.format().json) {
log.log(level, 'table', data); log.log(level, 'table', data);
} else { } else {
@ -186,7 +190,7 @@ cli.progress = function(label) {
// Draw initial progress // Draw initial progress
drawAndUpdateProgress(); drawAndUpdateProgress();
// Draw label // Draw label
if (label) { if (label) {
fs.writeSync(1, ' ' + label); fs.writeSync(1, ' ' + label);
@ -292,6 +296,7 @@ function enableNestedCommands(command) {
var args = command.rawArgs.slice(0, 2); var args = command.rawArgs.slice(0, 2);
var raw = command.normalize(command.rawArgs.slice(2)); var raw = command.normalize(command.rawArgs.slice(2));
var category = setupCommand(args, raw); var category = setupCommand(args, raw);
if (!command.categories[category]) { if (!command.categories[category]) {
log.error('\'' + category + '\' is not an azure command. See \'azure help\'.'); log.error('\'' + category + '\' is not an azure command. See \'azure help\'.');
} else { } else {