Skip to content

Commit

Permalink
Add debug output option.
Browse files Browse the repository at this point in the history
  • Loading branch information
rottmann committed Nov 13, 2014
1 parent 2d8b6f4 commit 767cda8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion bin/apidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ var argv = optimist

.option('h', { alias: 'help', boolean: true, describe: 'Show this help information.' })

.option('debug', { boolean: true, 'default': false, describe: 'Show debug messages.' })

.option('no-color', { boolean: true, 'default': false, describe: 'Turn off log color.' })

.option('parse', { boolean: true, 'default': false,
Expand Down Expand Up @@ -107,7 +109,8 @@ var defaults = {
src: argv['input'],
dest: argv['output'],
template: argv['template'],
verbose: argv['verbose'],
verbose: argv['debug'] === true ? argv['debug'] : argv['verbose'],
debug: argv['debug'],
parse: argv['parse'],
filters: transformToObject(argv['parse-filters']),
parsers: transformToObject(argv['parse-parsers']),
Expand Down
12 changes: 11 additions & 1 deletion lib/utils/console_logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var colors = require('colors');
* Console logger
*/
function Logger() {
this.isDebug = false;
this.isSilent = false;
this.isVerbose = true;
}
Expand All @@ -13,6 +14,15 @@ function Logger() {
*/
module.exports = new Logger();

/**
* Turn on/off debug log
*
* @param {Boolean} isSilent
*/
Logger.prototype.setDebug = function(isDebug) {
this.isDebug = (isDebug === true) ? true : false;
};

/**
* Turn on/off log
*
Expand All @@ -37,7 +47,7 @@ Logger.prototype.setVerbose = function(isVerbose) {
* @param {String} message
*/
Logger.prototype.debug = function(message, extra) {
if ( ! this.isSilent && this.isVerbose) {
if ( ! this.isSilent && this.isDebug) {
console.log(colors.cyan('debug: ') + message);
if (extra)
console.log(colors.white(this._getExtra(extra)));
Expand Down

0 comments on commit 767cda8

Please sign in to comment.