more linting
This commit is contained in:
parent
2192a094b6
commit
7cb7e6df72
@ -1,3 +1,4 @@
|
||||
"use strict";
|
||||
var vows = require('vows')
|
||||
, assert = require('assert')
|
||||
, sandbox = require('sandboxed-module');
|
||||
@ -14,8 +15,8 @@ function setupConsoleTest() {
|
||||
});
|
||||
|
||||
log4js = sandbox.require(
|
||||
'../lib/log4js'
|
||||
, {
|
||||
'../lib/log4js',
|
||||
{
|
||||
globals: {
|
||||
console: fakeConsole
|
||||
}
|
||||
@ -93,26 +94,25 @@ vows.describe('log4js').addBatch({
|
||||
|
||||
'configuration when passed as object': {
|
||||
topic: function() {
|
||||
var appenderConfig
|
||||
, log4js = sandbox.require(
|
||||
'../lib/log4js'
|
||||
, { requires:
|
||||
{ './appenders/file':
|
||||
var appenderConfig,
|
||||
log4js = sandbox.require(
|
||||
'../lib/log4js',
|
||||
{
|
||||
name: "file"
|
||||
, appender: function() {}
|
||||
, configure: function(configuration) {
|
||||
requires: {
|
||||
'./appenders/file':
|
||||
{
|
||||
name: "file",
|
||||
appender: function() {},
|
||||
configure: function(configuration) {
|
||||
appenderConfig = configuration;
|
||||
return function() {};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
, config = {
|
||||
"appenders": [
|
||||
{
|
||||
"type" : "file",
|
||||
),
|
||||
config = { appenders:
|
||||
[ { "type" : "file",
|
||||
"filename" : "cheesy-wotsits.log",
|
||||
"maxLogSize" : 1024,
|
||||
"backups" : 3
|
||||
@ -129,17 +129,18 @@ vows.describe('log4js').addBatch({
|
||||
|
||||
'configuration when passed as filename': {
|
||||
topic: function() {
|
||||
var appenderConfig
|
||||
, configFilename
|
||||
, log4js = sandbox.require(
|
||||
'../lib/log4js'
|
||||
, { requires:
|
||||
var appenderConfig,
|
||||
configFilename,
|
||||
log4js = sandbox.require(
|
||||
'../lib/log4js',
|
||||
{ requires:
|
||||
{ 'fs':
|
||||
{
|
||||
statSync: function() {
|
||||
{ statSync:
|
||||
function() {
|
||||
return { mtime: Date.now() };
|
||||
},
|
||||
readFileSync: function(filename) {
|
||||
readFileSync:
|
||||
function(filename) {
|
||||
configFilename = filename;
|
||||
return JSON.stringify({
|
||||
appenders: [
|
||||
@ -149,15 +150,15 @@ vows.describe('log4js').addBatch({
|
||||
]
|
||||
});
|
||||
},
|
||||
readdirSync: function() {
|
||||
readdirSync:
|
||||
function() {
|
||||
return ['file'];
|
||||
}
|
||||
}
|
||||
, './appenders/file':
|
||||
{
|
||||
name: "file"
|
||||
, appender: function() {}
|
||||
, configure: function(configuration) {
|
||||
},
|
||||
'./appenders/file':
|
||||
{ name: "file",
|
||||
appender: function() {},
|
||||
configure: function(configuration) {
|
||||
appenderConfig = configuration;
|
||||
return function() {};
|
||||
}
|
||||
@ -178,22 +179,22 @@ vows.describe('log4js').addBatch({
|
||||
|
||||
'with no appenders defined' : {
|
||||
topic: function() {
|
||||
var logger
|
||||
, that = this
|
||||
, fakeConsoleAppender = {
|
||||
name: "console"
|
||||
, appender: function() {
|
||||
var logger,
|
||||
that = this,
|
||||
fakeConsoleAppender = {
|
||||
name: "console",
|
||||
appender: function() {
|
||||
return function(evt) {
|
||||
that.callback(null, evt);
|
||||
}
|
||||
}
|
||||
, configure: function() {
|
||||
};
|
||||
},
|
||||
configure: function() {
|
||||
return fakeConsoleAppender.appender();
|
||||
}
|
||||
}
|
||||
, log4js = sandbox.require(
|
||||
'../lib/log4js'
|
||||
, {
|
||||
},
|
||||
log4js = sandbox.require(
|
||||
'../lib/log4js',
|
||||
{
|
||||
requires: {
|
||||
'./appenders/console': fakeConsoleAppender
|
||||
}
|
||||
@ -215,15 +216,22 @@ vows.describe('log4js').addBatch({
|
||||
},
|
||||
'without a category': {
|
||||
'should register the function as a listener for all loggers': function (log4js) {
|
||||
var appenderEvent, appender = function(evt) { appenderEvent = evt; }, logger = log4js.getLogger("tests");
|
||||
var appenderEvent,
|
||||
appender = function(evt) { appenderEvent = evt; },
|
||||
logger = log4js.getLogger("tests");
|
||||
|
||||
log4js.addAppender(appender);
|
||||
logger.debug("This is a test");
|
||||
assert.equal(appenderEvent.data[0], "This is a test");
|
||||
assert.equal(appenderEvent.categoryName, "tests");
|
||||
assert.equal(appenderEvent.level.toString(), "DEBUG");
|
||||
},
|
||||
'should also register as an appender for loggers if an appender for that category is defined': function (log4js) {
|
||||
var otherEvent, appenderEvent, cheeseLogger;
|
||||
'if an appender for a category is defined': {
|
||||
'should register for that category': function (log4js) {
|
||||
var otherEvent,
|
||||
appenderEvent,
|
||||
cheeseLogger;
|
||||
|
||||
log4js.addAppender(function (evt) { appenderEvent = evt; });
|
||||
log4js.addAppender(function (evt) { otherEvent = evt; }, 'cheese');
|
||||
|
||||
@ -239,11 +247,15 @@ vows.describe('log4js').addBatch({
|
||||
assert.isUndefined(otherEvent);
|
||||
assert.equal(appenderEvent.data[0], "this should not be propagated to otherEvent");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'with a category': {
|
||||
'should only register the function as a listener for that category': function(log4js) {
|
||||
var appenderEvent, appender = function(evt) { appenderEvent = evt; }, logger = log4js.getLogger("tests");
|
||||
var appenderEvent,
|
||||
appender = function(evt) { appenderEvent = evt; },
|
||||
logger = log4js.getLogger("tests");
|
||||
|
||||
log4js.addAppender(appender, 'tests');
|
||||
logger.debug('this is a category test');
|
||||
assert.equal(appenderEvent.data[0], 'this is a category test');
|
||||
@ -256,7 +268,10 @@ vows.describe('log4js').addBatch({
|
||||
|
||||
'with multiple categories': {
|
||||
'should register the function as a listener for all the categories': function(log4js) {
|
||||
var appenderEvent, appender = function(evt) { appenderEvent = evt; }, logger = log4js.getLogger('tests');
|
||||
var appenderEvent,
|
||||
appender = function(evt) { appenderEvent = evt; },
|
||||
logger = log4js.getLogger('tests');
|
||||
|
||||
log4js.addAppender(appender, 'tests', 'biscuits');
|
||||
|
||||
logger.debug('this is a test');
|
||||
@ -273,7 +288,9 @@ vows.describe('log4js').addBatch({
|
||||
assert.isUndefined(appenderEvent);
|
||||
},
|
||||
'should register the function when the list of categories is an array': function(log4js) {
|
||||
var appenderEvent, appender = function(evt) { appenderEvent = evt; };
|
||||
var appenderEvent,
|
||||
appender = function(evt) { appenderEvent = evt; };
|
||||
|
||||
log4js.addAppender(appender, ['tests', 'pants']);
|
||||
|
||||
log4js.getLogger('tests').debug('this is a test');
|
||||
@ -296,13 +313,13 @@ vows.describe('log4js').addBatch({
|
||||
topic: function() {
|
||||
var appenderEvents = [],
|
||||
fakeConsole = {
|
||||
'name': 'console'
|
||||
, 'appender': function () {
|
||||
'name': 'console',
|
||||
'appender': function () {
|
||||
return function(evt) {
|
||||
appenderEvents.push(evt);
|
||||
}
|
||||
}
|
||||
, 'configure': function (config) {
|
||||
};
|
||||
},
|
||||
'configure': function (config) {
|
||||
return fakeConsole.appender();
|
||||
}
|
||||
},
|
||||
@ -431,8 +448,12 @@ vows.describe('log4js').addBatch({
|
||||
modulePath = 'path/to/log4js.json',
|
||||
fakeFS = {
|
||||
lastMtime: Date.now(),
|
||||
config: { appenders: [ { type: 'console', layout: { type: 'messagePassThrough' } } ],
|
||||
levels: { 'a-test' : 'INFO' } },
|
||||
config: {
|
||||
appenders: [
|
||||
{ type: 'console', layout: { type: 'messagePassThrough' } }
|
||||
],
|
||||
levels: { 'a-test' : 'INFO' }
|
||||
},
|
||||
readdirSync: function(dir) {
|
||||
return require('fs').readdirSync(dir);
|
||||
},
|
||||
@ -506,8 +527,12 @@ vows.describe('log4js').addBatch({
|
||||
modulePath = require('path').normalize(__dirname + '/../lib/log4js.json'),
|
||||
mtime = new Date(),
|
||||
fakeFS = {
|
||||
config: { appenders: [ { type: 'console', layout: { type: 'messagePassThrough' } } ],
|
||||
levels: { 'a-test' : 'INFO' } },
|
||||
config: {
|
||||
appenders: [
|
||||
{ type: 'console', layout: { type: 'messagePassThrough' } }
|
||||
],
|
||||
levels: { 'a-test' : 'INFO' }
|
||||
},
|
||||
readdirSync: function(dir) {
|
||||
return require('fs').readdirSync(dir);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user