Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
Revert Logging (#3646)
Browse files Browse the repository at this point in the history
* Revert "two many underscores (#3638)"

This reverts commit 81475b3

Signed-off-by: Caroline Church <[email protected]>

* Revert "Serviceability issues (#3592)"

This reverts commit 0b9b607

Signed-off-by: Caroline Church <[email protected]>
  • Loading branch information
cazfletch authored and nklincoln committed Mar 21, 2018
1 parent f1b7a1f commit 898d024
Show file tree
Hide file tree
Showing 46 changed files with 1,295 additions and 1,573 deletions.
14 changes: 3 additions & 11 deletions packages/composer-cli/lib/cmds/network/lib/loglevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const chalk = require('chalk');
const cmdUtil = require('../../utils/cmdutils');
const Pretty = require('prettyjson');

/**
* <p>
* Composer "network loglevel" command
Expand Down Expand Up @@ -46,17 +46,9 @@ class LogLevel {
})
.then((result) => {
if (newlevel) {
cmdUtil.log(chalk.blue.bold('The logging level was successfully changed to: ')+newlevel);
cmdUtil.log(chalk.blue.bold('The logging level was successfully changed to: ') + newlevel);
} else {
cmdUtil.log(chalk.blue.bold('The current logging level is: ')+result.debug);
if(argv.x){
cmdUtil.log(chalk.blue.bold('\nFull details: '));
cmdUtil.log(Pretty.render(result,{
keysColor: 'blue',
dashColor: 'blue',
stringColor: 'white'
}));
}
cmdUtil.log(chalk.blue.bold('The current logging level is: ') + result);
}
});
}
Expand Down
5 changes: 2 additions & 3 deletions packages/composer-cli/lib/cmds/network/loglevelCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ const logLevel = require ('./lib/loglevel.js');
module.exports.command = 'loglevel [options]';
module.exports.describe = 'Change the logging level of a business network';
module.exports.builder = {
newlevel: { alias: 'l', optional: true, describe: 'the new logging level', type: 'string'},
card: { alias: 'c', required: true, description: 'The cardname to use to change the log level the network', type:'string'},
full: { alias: 'x', required: false, description: 'The full settings of the currently configured debug log', hidden: true},
newlevel: { alias: 'l', optional: true, describe: 'the new logging level', choices : ['INFO', 'WARNING', 'ERROR', 'DEBUG'] },
card: { alias: 'c', required: true, description: 'The cardname to use to change the log level the network', type:'string'}
};

module.exports.handler = (argv) => {
Expand Down
14 changes: 0 additions & 14 deletions packages/composer-cli/test/network/loglevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,5 @@ describe('composer network logLevel CLI unit tests', () => {
});
});

it('should get the logLevel and produce the full-output', () => {
let argv = {
card:'cardname' ,
x: true
};

return LogLevel.handler(argv)
.then((res) => {
argv.thePromise.should.be.a('promise');
sinon.assert.calledOnce(mockAdminConnection.connect);
sinon.assert.calledWith(mockAdminConnection.connect, 'cardname');
sinon.assert.calledOnce(mockAdminConnection.getLogLevel);

});
});
});
39 changes: 18 additions & 21 deletions packages/composer-common/lib/log/consolelogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@
const util = require('util');

/**
* A functional logger implementation that simply writes to the console.
* @private
*/
class ConsoleLogger {

/**
* Called to format.
* @param {string} method The method.
* @param {string} msg The message.
* @param {*} [args] The arguments.
* @returns {string} The formatted message.
* @private
*/
/**
* Called to format.
* @param {string} method The method.
* @param {string} msg The message.
* @param {*} [args] The arguments.
* @returns {string} The formatted message.
*/
format(method, msg, args) {
if (!args) {
return util.format('%s %s', method, msg);
}
let formattedArguments = args.map((arg) => {
if (typeof (arg) === 'function') {
if (typeof(arg) === 'function') {
return '<function>';
} else if (arg === Object(arg)) {
// It's an object, array, or function, so serialize it as JSON.
// It's an object, array, or function, so serialize it as JSON.
try {
return JSON.stringify(arg);
} catch (e) {
Expand All @@ -50,14 +50,13 @@ class ConsoleLogger {
return util.format('%s %s %s', method, msg, formattedArguments);
}

/**
* Called to log.
* @param {string} level The logging level.
* @param {string} method The method.
* @param {string} msg The message.
* @param {*} [args] The arguments.
* @private
*/
/**
* Called to log.
* @param {string} level The logging level.
* @param {string} method The method.
* @param {string} msg The message.
* @param {*} [args] The arguments.
*/
log(level, method, msg, args) {
const formattedMessage = this.format(method, msg, args);
switch (level) {
Expand All @@ -81,6 +80,4 @@ class ConsoleLogger {

}

module.exports.getLogger = function (config) {
return new ConsoleLogger();
};
module.exports = ConsoleLogger;
Loading

0 comments on commit 898d024

Please sign in to comment.