changed logger to not use events. everything is broken

This commit is contained in:
Gareth Jones
2013-08-02 11:36:05 +10:00
parent d25e1abd48
commit 3b55aefe6f
4 changed files with 59 additions and 59 deletions

View File

@@ -2,7 +2,8 @@
var vows = require('vows')
, assert = require('assert')
, levels = require('../lib/levels')
, Logger = require('../lib/logger').Logger;
, Logger = require('../lib/logger').Logger
, log4js = require('../lib/log4js');
vows.describe('../lib/logger').addBatch({
'constructor with no parameters': {
@@ -53,5 +54,22 @@ vows.describe('../lib/logger').addBatch({
assert.isTrue(logger.isErrorEnabled());
assert.isTrue(logger.isFatalEnabled());
}
},
'log': {
topic: new Logger('testing'),
'should send log events to log4js': function(logger) {
var evt, original = log4js.dispatch;
log4js.dispatch = function(event) {
evt = event;
};
logger.log(levels.DEBUG, "cheese");
log4js.dispatch = original;
assert.equal(evt.categoryName, 'testing');
assert.equal(evt.level, levels.DEBUG);
assert.equal(evt.data[0], "cheese");
}
}
}).exportTo(module);

View File

@@ -54,7 +54,7 @@ vows.describe('log4js').addBatch({
'log events' : {
topic: function(logger) {
var events = [];
logger.addListener("log", function (logEvent) { events.push(logEvent); });
log4js.addAppender(function (logEvent) { events.push(logEvent); }, "tests");
logger.debug("Debug event");
logger.trace("Trace event 1");
logger.trace("Trace event 2");
@@ -83,7 +83,7 @@ vows.describe('log4js').addBatch({
},
},
/*
'invalid configuration': {
'should throw an exception': function() {
assert.throws(function() {
@@ -509,4 +509,5 @@ vows.describe('log4js').addBatch({
assert.ok(logger.error);
}
}
*/
}).export(module);