Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[api test] Added
.cli()
method for pretty formatting CLI output
- Loading branch information
Showing
5 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* cli-config.js: Config that conform to commonly used CLI logging levels. | ||
* | ||
* (C) 2010 Charlie Robbins | ||
* MIT LICENCE | ||
* | ||
*/ | ||
|
||
var cliConfig = exports; | ||
|
||
cliConfig.levels = { | ||
silly: 0, | ||
input: 1, | ||
verbose: 2, | ||
prompt: 3, | ||
info: 4, | ||
data: 5, | ||
help: 6, | ||
warn: 7, | ||
debug: 8, | ||
error: 9 | ||
}; | ||
|
||
cliConfig.colors = { | ||
silly: 'magenta', | ||
input: 'grey', | ||
verbose: 'cyan', | ||
prompt: 'grey', | ||
info: 'green', | ||
data: 'grey', | ||
help: 'cyan', | ||
warn: 'yellow', | ||
debug: 'blue', | ||
error: 'red' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* cli-test.js: Tests for the cli levels available in winston. | ||
* | ||
* (C) 2010 Charlie Robbins | ||
* MIT LICENSE | ||
* | ||
*/ | ||
|
||
require.paths.unshift(require('path').join(__dirname, '..', 'lib')); | ||
|
||
var path = require('path'), | ||
vows = require('vows'), | ||
assert = require('assert'), | ||
winston = require('winston'), | ||
helpers = require('./helpers'); | ||
|
||
vows.describe('winston/logger/cli').addBatch({ | ||
"When an instance of winston.Logger": { | ||
topic: function () { | ||
return new winston.Logger({ | ||
transports: [ | ||
new winston.transports.Console() | ||
] | ||
}) | ||
}, | ||
"the cli() method": { | ||
"should set the appropriate values on the logger": function (logger) { | ||
logger.cli(); | ||
assert.isTrue(logger.padLevels); | ||
assert.isTrue(logger.transports.console.colorize); | ||
assert.isFalse(logger.transports.console.timestamp); | ||
Object.keys(winston.config.cli.levels).forEach(function (level) { | ||
assert.isNumber(logger.levels[level]); | ||
}); | ||
|
||
Object.keys(winston.config.cli.colors).forEach(function (color) { | ||
assert.isString(winston.config.allColors[color]); | ||
}); | ||
} | ||
} | ||
} | ||
}).export(module); |