Use 10/20/... instead of 1/2/... for level constant values.

This commit is contained in:
Trent Mick 2012-02-06 15:23:51 -08:00
parent 140c9fda91
commit 25b8eeabc9
5 changed files with 30 additions and 26 deletions

View file

@ -2,6 +2,11 @@
## bunyan 0.5.0 (not yet released) ## bunyan 0.5.0 (not yet released)
- Use 10/20/... instead of 1/2/... for level constant values. Ostensibly this
allows for intermediary levels from the defined "trace/debug/..." set.
However, that is discouraged. I'd need a strong user argument to add
support for easily using alternative levels. Consider using a separate
JSON field instead.
- s/service/name/ for Logger name field. "service" is unnecessarily tied - s/service/name/ for Logger name field. "service" is unnecessarily tied
to usage for a service. No need to differ from log4j Logger "name". to usage for a service. No need to differ from log4j Logger "name".
- Add `log.level(...)` and `log.levels(...)` API for changing logger stream - Add `log.level(...)` and `log.levels(...)` API for changing logger stream

View file

@ -203,12 +203,12 @@ in production.**
# Levels # Levels
- "fatal" (6): the service/app is going to stop or become unusable now - "fatal" (60): the service/app is going to stop or become unusable now
- "error" (5): fatal for a particular request, but the service/app continues servicing other requests - "error" (50): fatal for a particular request, but the service/app continues servicing other requests
- "warn" (4): a note on something that should probably be looked at by an operator - "warn" (40): a note on something that should probably be looked at by an operator
- "info" (3): detail on regular operation - "info" (30): detail on regular operation
- "debug" (2): anything else, i.e. too verbose to be included in "info" level. - "debug" (20): anything else, i.e. too verbose to be included in "info" level.
- "trace" (1): logging from external libraries used by your app - "trace" (10): logging from external libraries used by your app
"debug" should be used sparingly. Information that will be useful to debug "debug" should be used sparingly. Information that will be useful to debug
errors *post mortem* should usually be included in "info" messages if it's errors *post mortem* should usually be included in "info" messages if it's

View file

@ -1,7 +1,3 @@
- Logger.setLevel()? How to change level for a given stream. Default all,
else, give an index... or type ... or support stream "names". Some positives
to stream names.
- service -> name
- 10, 20,... - 10, 20,...
- bunyan cli: more layouts (http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/EnhancedPatternLayout.html) - bunyan cli: more layouts (http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/EnhancedPatternLayout.html)
Custom log formats (in config file? in '-f' arg) using printf or hogan.js Custom log formats (in config file? in '-f' arg) using printf or hogan.js

View file

@ -31,12 +31,12 @@ var OM_FROM_NAME = {
// Levels // Levels
var TRACE = 1; var TRACE = 10;
var DEBUG = 2; var DEBUG = 20;
var INFO = 3; var INFO = 30;
var WARN = 4; var WARN = 40;
var ERROR = 5; var ERROR = 50;
var FATAL = 6; var FATAL = 60;
var levelFromName = { var levelFromName = {
'trace': TRACE, 'trace': TRACE,
@ -46,9 +46,13 @@ var levelFromName = {
'error': ERROR, 'error': ERROR,
'fatal': FATAL 'fatal': FATAL
}; };
var nameFromLevel = [undefined].concat(Object.keys(levelFromName)); var nameFromLevel = {};
var upperNameFromLevel = [undefined].concat( var upperNameFromLevel = {};
Object.keys(levelFromName).map(function (l) { return l.toUpperCase(); })); Object.keys(levelFromName).forEach(function (name) {
var lvl = levelFromName[name];
nameFromLevel[lvl] = name;
upperNameFromLevel[lvl] = name.toUpperCase();
});

View file

@ -112,12 +112,12 @@ function getCaller3Info() {
//---- Levels //---- Levels
var TRACE = 1; var TRACE = 10;
var DEBUG = 2; var DEBUG = 20;
var INFO = 3; var INFO = 30;
var WARN = 4; var WARN = 40;
var ERROR = 5; var ERROR = 50;
var FATAL = 6; var FATAL = 60;
var levelFromName = { var levelFromName = {
'trace': TRACE, 'trace': TRACE,
@ -127,7 +127,6 @@ var levelFromName = {
'error': ERROR, 'error': ERROR,
'fatal': FATAL 'fatal': FATAL
}; };
var nameFromLevel = [undefined].concat(Object.keys(levelFromName));
function resolveLevel(nameOrNum) { function resolveLevel(nameOrNum) {
var level = (typeof(nameOrNum) === 'string' var level = (typeof(nameOrNum) === 'string'