formatting
This commit is contained in:
Родитель
b8e43bde23
Коммит
7b61c5e384
|
@ -33,7 +33,7 @@ var istty1 = tty.isatty(1);
|
|||
if (!process.env.AZURE_DEBUG || process.env.AZURE_DEBUG !== '1') {
|
||||
process.on('uncaughtException', function (err) {
|
||||
clearProgress();
|
||||
|
||||
|
||||
var loggedFullError = false;
|
||||
if (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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
// prepare output logger
|
||||
|
||||
// use cli output settings by default
|
||||
log.cli();
|
||||
|
||||
log.format = function(options) {
|
||||
var transport = log['default'].transports.console;
|
||||
log.format = function (options) {
|
||||
var transport = log['default'].transports.console;
|
||||
if (arguments.length === 0) {
|
||||
return {
|
||||
json: transport.json,
|
||||
|
@ -73,20 +72,23 @@ log.format = function(options) {
|
|||
logo: log.format.logo
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if (options.json) {
|
||||
log.padLevels = false;
|
||||
log.stripColors = true;
|
||||
transport.json = true;
|
||||
transport.terse = true;
|
||||
}
|
||||
|
||||
if (options.terse) {
|
||||
log.padLevels = false;
|
||||
transport.terse = true;
|
||||
}
|
||||
|
||||
if (options.level) {
|
||||
transport.level = options.level;
|
||||
}
|
||||
|
||||
if (options.logo) {
|
||||
log.format.logo = options.logo;
|
||||
}
|
||||
|
@ -98,12 +100,13 @@ log.json = function (level, data) {
|
|||
data = level;
|
||||
level = 'data';
|
||||
}
|
||||
|
||||
if (log.format().json) {
|
||||
log.log(level, typeof data, data);
|
||||
} else {
|
||||
var lines = eyes.inspect(data, level, { stream: false });
|
||||
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
|
||||
// splitting the eyes formatting and inserting winston formatting where it
|
||||
// wasn't before.
|
||||
|
@ -119,6 +122,7 @@ log.table = function (level, data, transform) {
|
|||
data = level;
|
||||
level = 'data';
|
||||
}
|
||||
|
||||
if (log.format().json) {
|
||||
log.log(level, 'table', data);
|
||||
} else {
|
||||
|
@ -186,7 +190,7 @@ cli.progress = function(label) {
|
|||
|
||||
// Draw initial progress
|
||||
drawAndUpdateProgress();
|
||||
|
||||
|
||||
// Draw label
|
||||
if (label) {
|
||||
fs.writeSync(1, ' ' + label);
|
||||
|
@ -292,6 +296,7 @@ function enableNestedCommands(command) {
|
|||
var args = command.rawArgs.slice(0, 2);
|
||||
var raw = command.normalize(command.rawArgs.slice(2));
|
||||
var category = setupCommand(args, raw);
|
||||
|
||||
if (!command.categories[category]) {
|
||||
log.error('\'' + category + '\' is not an azure command. See \'azure help\'.');
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче