working, except for tests which expect log levels to persist across getLogger calls
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
var levels = require('./levels')
|
||||
var debug = require('./debug')('logger')
|
||||
, levels = require('./levels')
|
||||
, util = require('util')
|
||||
, log4js = require('./log4js')
|
||||
, DEFAULT_CATEGORY = '[default]';
|
||||
|
||||
/**
|
||||
@@ -26,17 +26,20 @@ function LoggingEvent (categoryName, level, data) {
|
||||
* @param name name of category to log to
|
||||
* @author Stephan Strittmatter
|
||||
*/
|
||||
function Logger (name, level) {
|
||||
function Logger (name, level, dispatch) {
|
||||
this.category = name || DEFAULT_CATEGORY;
|
||||
|
||||
if (level) {
|
||||
this.setLevel(level);
|
||||
}
|
||||
|
||||
this.dispatch = dispatch;
|
||||
}
|
||||
Logger.DEFAULT_CATEGORY = DEFAULT_CATEGORY;
|
||||
Logger.prototype.level = levels.TRACE;
|
||||
|
||||
Logger.prototype.setLevel = function(level) {
|
||||
debug("setting level to " + level);
|
||||
this.level = levels.toLevel(level, this.level || levels.TRACE);
|
||||
};
|
||||
|
||||
@@ -48,8 +51,8 @@ Logger.prototype.log = function() {
|
||||
var args = Array.prototype.slice.call(arguments)
|
||||
, logLevel = args.shift()
|
||||
, loggingEvent = new LoggingEvent(this.category, logLevel, args);
|
||||
|
||||
log4js.dispatch(loggingEvent);
|
||||
debug("Logging event " + loggingEvent + " to dispatch = " + util.inspect(this.dispatch));
|
||||
this.dispatch(loggingEvent);
|
||||
};
|
||||
|
||||
Logger.prototype.isLevelEnabled = function(otherLevel) {
|
||||
|
||||
Reference in New Issue
Block a user