fixing some lint issues
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"build": "clean lint coverage test",
|
"build": "clean lint test coverage",
|
||||||
"lint": {
|
"lint": {
|
||||||
"type": "jshint"
|
"type": "jshint"
|
||||||
},
|
},
|
||||||
"coverage": {
|
"coverage": {
|
||||||
"type": "vows"
|
"type": "mocha-istanbul"
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
"type": "vows"
|
"type": "mocha"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
"maxlen": 100,
|
"maxlen": 100,
|
||||||
"globals": {
|
"globals": {
|
||||||
"describe": true,
|
"describe": true,
|
||||||
"it": true
|
"it": true,
|
||||||
|
"before": true,
|
||||||
|
"beforeEach": true,
|
||||||
|
"after": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,6 @@ function configure(config, options) {
|
|||||||
config.alwaysIncludePattern = false;
|
config.alwaysIncludePattern = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options && options.cwd && !config.absolute) {
|
|
||||||
config.filename = path.join(options.cwd, config.filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
return appender(config.filename, config.pattern, config.alwaysIncludePattern, layout);
|
return appender(config.filename, config.pattern, config.alwaysIncludePattern, layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-11
@@ -160,20 +160,17 @@ function patternLayout (pattern, tokens) {
|
|||||||
return loggerName;
|
return loggerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var formats = {
|
||||||
|
"ISO8601": dateFormat.ISO8601_FORMAT,
|
||||||
|
"ISO8601_WITH_TZ_OFFSET": dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT,
|
||||||
|
"ABSOLUTE": dateFormat.ABSOLUTETIME_FORMAT,
|
||||||
|
"DATE": dateFormat.DATETIME_FORMAT
|
||||||
|
};
|
||||||
|
|
||||||
function formatAsDate(loggingEvent, specifier) {
|
function formatAsDate(loggingEvent, specifier) {
|
||||||
var format = dateFormat.ISO8601_FORMAT;
|
var format = dateFormat.ISO8601_FORMAT;
|
||||||
if (specifier) {
|
if (specifier) {
|
||||||
format = specifier;
|
format = formats[specifier] || specifier;
|
||||||
// Pick up special cases
|
|
||||||
if (format == "ISO8601") {
|
|
||||||
format = dateFormat.ISO8601_FORMAT;
|
|
||||||
} else if (format == "ISO8601_WITH_TZ_OFFSET") {
|
|
||||||
format = dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT;
|
|
||||||
} else if (format == "ABSOLUTE") {
|
|
||||||
format = dateFormat.ABSOLUTETIME_FORMAT;
|
|
||||||
} else if (format == "DATE") {
|
|
||||||
format = dateFormat.DATETIME_FORMAT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Format the date
|
// Format the date
|
||||||
return dateFormat.asString(format, loggingEvent.startTime);
|
return dateFormat.asString(format, loggingEvent.startTime);
|
||||||
|
|||||||
+32
-11
@@ -125,7 +125,14 @@ function workerDispatch(event) {
|
|||||||
function dispatch(event) {
|
function dispatch(event) {
|
||||||
debug("event is ", event);
|
debug("event is ", event);
|
||||||
var category = categories[event.category] || categories.default;
|
var category = categories[event.category] || categories.default;
|
||||||
debug("category.level[", category.level, "] <= ", event.level, " ? ", category.level.isLessThanOrEqualTo(event.level));
|
debug(
|
||||||
|
"category.level[",
|
||||||
|
category.level,
|
||||||
|
"] <= ",
|
||||||
|
event.level,
|
||||||
|
" ? ",
|
||||||
|
category.level.isLessThanOrEqualTo(event.level)
|
||||||
|
);
|
||||||
|
|
||||||
if (category.level.isLessThanOrEqualTo(event.level)) {
|
if (category.level.isLessThanOrEqualTo(event.level)) {
|
||||||
category.appenders.forEach(function(appender) {
|
category.appenders.forEach(function(appender) {
|
||||||
@@ -182,7 +189,11 @@ function validateCategories(cats) {
|
|||||||
}
|
}
|
||||||
category.level = levels.toLevel(inputLevel);
|
category.level = levels.toLevel(inputLevel);
|
||||||
if (!category.level) {
|
if (!category.level) {
|
||||||
throw new Error("Level '" + inputLevel + "' is not valid for category '" + categoryName + "'. Acceptable values are: " + levels.levels.join(', ') + ".");
|
throw new Error(
|
||||||
|
"Level '" + inputLevel +
|
||||||
|
"' is not valid for category '" + categoryName +
|
||||||
|
"'. Acceptable values are: " + levels.levels.join(', ') + "."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!category.appenders || !category.appenders.length) {
|
if (!category.appenders || !category.appenders.length) {
|
||||||
@@ -191,7 +202,11 @@ function validateCategories(cats) {
|
|||||||
|
|
||||||
category.appenders.forEach(function(appender) {
|
category.appenders.forEach(function(appender) {
|
||||||
if (!appenders[appender]) {
|
if (!appenders[appender]) {
|
||||||
throw new Error("Appender '" + appender + "' for category '" + categoryName + "' does not exist. Known appenders are: " + Object.keys(appenders).join(', ') + ".");
|
throw new Error(
|
||||||
|
"Appender '" + appender +
|
||||||
|
"' for category '" + categoryName +
|
||||||
|
"' does not exist. Known appenders are: " + Object.keys(appenders).join(', ') + "."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -213,14 +228,20 @@ function appenderByName(name) {
|
|||||||
function configureAppenders(appenderMap) {
|
function configureAppenders(appenderMap) {
|
||||||
clearAppenders();
|
clearAppenders();
|
||||||
Object.keys(appenderMap).forEach(function(appenderName) {
|
Object.keys(appenderMap).forEach(function(appenderName) {
|
||||||
var appender, appenderConfig = appenderMap[appenderName];
|
var appender, appenderConfig = appenderMap[appenderName];
|
||||||
loadAppender(appenderConfig.type);
|
loadAppender(appenderConfig.type);
|
||||||
appenderConfig.makers = appenderMakers;
|
appenderConfig.makers = appenderMakers;
|
||||||
try {
|
try {
|
||||||
appenders[appenderName] = appenderMakers[appenderConfig.type](appenderConfig, appenderByName);
|
appenders[appenderName] = appenderMakers[appenderConfig.type](
|
||||||
} catch(e) {
|
appenderConfig,
|
||||||
throw new Error("log4js configuration problem for appender '" + appenderName + "'. Error was " + e.stack);
|
appenderByName
|
||||||
}
|
);
|
||||||
|
} catch(e) {
|
||||||
|
throw new Error(
|
||||||
|
"log4js configuration problem for appender '" + appenderName +
|
||||||
|
"'. Error was " + e.stack
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,10 @@ describe('log4js', function() {
|
|||||||
'utf8',
|
'utf8',
|
||||||
function(err, contents) {
|
function(err, contents) {
|
||||||
var lines = contents.trim().split('\n');
|
var lines = contents.trim().split('\n');
|
||||||
lines.should.eql(["This should not", "This shouldn't be included by the appender anyway"]);
|
lines.should.eql([
|
||||||
|
"This should not",
|
||||||
|
"This shouldn't be included by the appender anyway"
|
||||||
|
]);
|
||||||
done(err);
|
done(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ describe('log4js in a cluster', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should listen for fork events', function() {
|
it('should listen for fork events', function() {
|
||||||
clusterOnFork.should.be.true;
|
clusterOnFork.should.eql(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should listen for messages from workers', function() {
|
it('should listen for messages from workers', function() {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ describe('../lib/appenders/console', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should output to console', function() {
|
it('should output to console', function() {
|
||||||
messages.should.eql(["blah"]);
|
messages.should.eql(["blah"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
/*jshint expr:true */
|
||||||
var should = require('should')
|
var should = require('should')
|
||||||
, async = require('async')
|
, async = require('async')
|
||||||
, path = require('path')
|
, path = require('path')
|
||||||
|
|||||||
@@ -15,10 +15,20 @@ describe('date_format', function() {
|
|||||||
|
|
||||||
it('should provide a ISO8601 with timezone offset format', function() {
|
it('should provide a ISO8601 with timezone offset format', function() {
|
||||||
date.getTimezoneOffset = function() { return -660; };
|
date.getTimezoneOffset = function() { return -660; };
|
||||||
dateFormat.asString(dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT, date).should.eql("2010-01-11T14:31:30+1100");
|
dateFormat.asString(
|
||||||
|
dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT,
|
||||||
|
date
|
||||||
|
).should.eql(
|
||||||
|
"2010-01-11T14:31:30+1100"
|
||||||
|
);
|
||||||
|
|
||||||
date.getTimezoneOffset = function() { return 120; };
|
date.getTimezoneOffset = function() { return 120; };
|
||||||
dateFormat.asString(dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT, date).should.eql("2010-01-11T14:31:30-0200");
|
dateFormat.asString(
|
||||||
|
dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT,
|
||||||
|
date
|
||||||
|
).should.eql(
|
||||||
|
"2010-01-11T14:31:30-0200"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a just-the-time format', function() {
|
it('should provide a just-the-time format', function() {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
/*jshint expr:true */
|
||||||
var fs = require('fs')
|
var fs = require('fs')
|
||||||
, async = require('async')
|
, async = require('async')
|
||||||
, path = require('path')
|
, path = require('path')
|
||||||
@@ -18,9 +19,12 @@ describe('log4js fileAppender', function() {
|
|||||||
before(function() {
|
before(function() {
|
||||||
var logfile
|
var logfile
|
||||||
, count = 5
|
, count = 5
|
||||||
, config = { appenders: {}, categories: { default: { level: "debug", appenders: ["file0"] } } };
|
, config = {
|
||||||
|
appenders: {},
|
||||||
|
categories: { default: { level: "debug", appenders: ["file0"] } }
|
||||||
|
};
|
||||||
|
|
||||||
initialCount = process.listeners('exit').length
|
initialCount = process.listeners('exit').length;
|
||||||
|
|
||||||
while (count--) {
|
while (count--) {
|
||||||
logfile = path.join(__dirname, '/fa-default-test' + count + '.log');
|
logfile = path.join(__dirname, '/fa-default-test' + count + '.log');
|
||||||
@@ -98,7 +102,7 @@ describe('log4js fileAppender', function() {
|
|||||||
"file": { type: "file", filename: testFile }
|
"file": { type: "file", filename: testFile }
|
||||||
},
|
},
|
||||||
categories: {
|
categories: {
|
||||||
default: { level: "debug", appenders: [ "file" ] }
|
"default": { level: "debug", appenders: [ "file" ] }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -147,7 +151,7 @@ describe('log4js fileAppender', function() {
|
|||||||
"file": { type: "file", filename: testFile, maxLogSize: 100, backups: 0 }
|
"file": { type: "file", filename: testFile, maxLogSize: 100, backups: 0 }
|
||||||
},
|
},
|
||||||
categories: {
|
categories: {
|
||||||
default: { level: "debug", appenders: [ "file" ] }
|
"default": { level: "debug", appenders: [ "file" ] }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
logger.info("This is the first log message.");
|
logger.info("This is the first log message.");
|
||||||
@@ -206,7 +210,7 @@ describe('log4js fileAppender', function() {
|
|||||||
"file": { type: "file", filename: testFile, maxLogSize: 50, backups: 2 }
|
"file": { type: "file", filename: testFile, maxLogSize: 50, backups: 2 }
|
||||||
},
|
},
|
||||||
categories: {
|
categories: {
|
||||||
default: { level: "debug", appenders: [ "file" ] }
|
"default": { level: "debug", appenders: [ "file" ] }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -315,7 +319,8 @@ describe('log4js fileAppender', function() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
fileAppender.configure({
|
fileAppender.configure({
|
||||||
filename: 'test1.log', maxLogSize: 100
|
filename: 'test1.log',
|
||||||
|
maxLogSize: 100
|
||||||
});
|
});
|
||||||
errorHandler({ error: 'aargh' });
|
errorHandler({ error: 'aargh' });
|
||||||
});
|
});
|
||||||
|
|||||||
+40
-35
@@ -76,22 +76,19 @@ describe('log4js layouts', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should print the stacks of a passed error objects', function() {
|
it('should print the stacks of a passed error objects', function() {
|
||||||
assert.ok(
|
assert.ok(Array.isArray(
|
||||||
Array.isArray(
|
layout({
|
||||||
layout({
|
data: [ new Error() ],
|
||||||
data: [ new Error() ],
|
startTime: new Date(2010, 11, 5, 14, 18, 30, 45),
|
||||||
startTime: new Date(2010, 11, 5, 14, 18, 30, 45),
|
category: "cheese",
|
||||||
category: "cheese",
|
level: {
|
||||||
level: {
|
colour: "green",
|
||||||
colour: "green",
|
toString: function() { return "ERROR"; }
|
||||||
toString: function() { return "ERROR"; }
|
}
|
||||||
}
|
}).match(
|
||||||
}).match(
|
/Error\s+at Context\..*\s+\((.*)test[\\\/]layouts-test\.js\:\d+\:\d+\)\s/
|
||||||
/Error\s+at Context\..*\s+\((.*)test[\\\/]layouts-test\.js\:\d+\:\d+\)\s/
|
)
|
||||||
)
|
), 'regexp did not return a match');
|
||||||
),
|
|
||||||
'regexp did not return a match'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with passed augmented errors', function() {
|
describe('with passed augmented errors', function() {
|
||||||
@@ -203,7 +200,13 @@ describe('log4js layouts', function() {
|
|||||||
event.startTime.getTimezoneOffset = function() { return 0; };
|
event.startTime.getTimezoneOffset = function() { return 0; };
|
||||||
|
|
||||||
it('should default to "time logLevel loggerName - message"', function() {
|
it('should default to "time logLevel loggerName - message"', function() {
|
||||||
test(layout, event, tokens, null, "14:18:30 DEBUG multiple.levels.of.tests - this is a test\n");
|
test(
|
||||||
|
layout,
|
||||||
|
event,
|
||||||
|
tokens,
|
||||||
|
null,
|
||||||
|
"14:18:30 DEBUG multiple.levels.of.tests - this is a test\n"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('%r should output time only', function() {
|
it('%r should output time only', function() {
|
||||||
@@ -295,24 +298,26 @@ describe('log4js layouts', function() {
|
|||||||
test(layout, event, tokens, '%[%r%]', '\x1B[36m14:18:30\x1B[39m');
|
test(layout, event, tokens, '%[%r%]', '\x1B[36m14:18:30\x1B[39m');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('%x{testString} should output the string stored in tokens', function() {
|
describe('%x{}', function() {
|
||||||
test(layout, event, tokens, '%x{testString}', 'testStringToken');
|
it('%x{testString} should output the string stored in tokens', function() {
|
||||||
});
|
test(layout, event, tokens, '%x{testString}', 'testStringToken');
|
||||||
|
});
|
||||||
it('%x{testFunction} should output the result of the function stored in tokens', function() {
|
|
||||||
test(layout, event, tokens, '%x{testFunction}', 'testFunctionToken');
|
it('%x{testFunction} should output the result of the function stored in tokens', function() {
|
||||||
});
|
test(layout, event, tokens, '%x{testFunction}', 'testFunctionToken');
|
||||||
|
});
|
||||||
it('%x{doesNotExist} should output the string stored in tokens', function() {
|
|
||||||
test(layout, event, tokens, '%x{doesNotExist}', '%x{doesNotExist}');
|
it('%x{doesNotExist} should output the string stored in tokens', function() {
|
||||||
});
|
test(layout, event, tokens, '%x{doesNotExist}', '%x{doesNotExist}');
|
||||||
|
});
|
||||||
it('%x{fnThatUsesLogEvent} should be able to use the logEvent', function() {
|
|
||||||
test(layout, event, tokens, '%x{fnThatUsesLogEvent}', 'DEBUG');
|
it('%x{fnThatUsesLogEvent} should be able to use the logEvent', function() {
|
||||||
});
|
test(layout, event, tokens, '%x{fnThatUsesLogEvent}', 'DEBUG');
|
||||||
|
});
|
||||||
it('%x should output the string stored in tokens', function() {
|
|
||||||
test(layout, event, tokens, '%x', '%x');
|
it('%x should output the string stored in tokens', function() {
|
||||||
|
test(layout, event, tokens, '%x', '%x');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -417,6 +417,11 @@ describe('../lib/levels', function() {
|
|||||||
it('should return the default value if argument is not recognised', function() {
|
it('should return the default value if argument is not recognised', function() {
|
||||||
levels.toLevel("cheese", levels.DEBUG).should.eql(levels.DEBUG);
|
levels.toLevel("cheese", levels.DEBUG).should.eql(levels.DEBUG);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return the default value if argument is falsy', function() {
|
||||||
|
levels.toLevel(undefined, levels.DEBUG).should.eql(levels.DEBUG);
|
||||||
|
levels.toLevel(null, levels.DEBUG).should.eql(levels.DEBUG);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
+44
-37
@@ -54,40 +54,44 @@ describe('../lib/log4js', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should complain if the config does not specify an appender for the default category', function() {
|
it(
|
||||||
|
'should complain if the config does not specify an appender for the default category',
|
||||||
(function() {
|
function() {
|
||||||
log4js.configure(
|
|
||||||
{
|
(function() {
|
||||||
|
log4js.configure(
|
||||||
|
{
|
||||||
|
appenders: {
|
||||||
|
"console": { type: "console" }
|
||||||
|
},
|
||||||
|
categories: {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}).should.throw(
|
||||||
|
"You must specify an appender for the default category"
|
||||||
|
);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
log4js.configure({
|
||||||
appenders: {
|
appenders: {
|
||||||
"console": { type: "console" }
|
"console": { type: "console" }
|
||||||
},
|
},
|
||||||
categories: {}
|
categories: {
|
||||||
}
|
"cheese": { level: "DEBUG", appenders: [ "console" ] }
|
||||||
);
|
}
|
||||||
}).should.throw(
|
});
|
||||||
"You must specify an appender for the default category"
|
}).should.throw(
|
||||||
);
|
"You must specify an appender for the default category"
|
||||||
|
);
|
||||||
(function() {
|
|
||||||
log4js.configure({
|
}
|
||||||
appenders: {
|
);
|
||||||
"console": { type: "console" }
|
|
||||||
},
|
|
||||||
categories: {
|
|
||||||
"cheese": { level: "DEBUG", appenders: [ "console" ] }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).should.throw(
|
|
||||||
"You must specify an appender for the default category"
|
|
||||||
);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should complain if a category does not specify level or appenders', function() {
|
it('should complain if a category does not specify level or appenders', function() {
|
||||||
(function() {
|
(function() {
|
||||||
log4js.configure(
|
log4js.configure(
|
||||||
{ appenders: { "console": { type: "console" } },
|
{
|
||||||
|
appenders: { "console": { type: "console" } },
|
||||||
categories: {
|
categories: {
|
||||||
"default": { thing: "thing" }
|
"default": { thing: "thing" }
|
||||||
}
|
}
|
||||||
@@ -99,7 +103,8 @@ describe('../lib/log4js', function() {
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
log4js.configure(
|
log4js.configure(
|
||||||
{ appenders: { "console": { type: "console" } },
|
{
|
||||||
|
appenders: { "console": { type: "console" } },
|
||||||
categories: {
|
categories: {
|
||||||
"default": { level: "DEBUG" }
|
"default": { level: "DEBUG" }
|
||||||
}
|
}
|
||||||
@@ -113,7 +118,8 @@ describe('../lib/log4js', function() {
|
|||||||
it('should complain if a category specifies a level that does not exist', function() {
|
it('should complain if a category specifies a level that does not exist', function() {
|
||||||
(function() {
|
(function() {
|
||||||
log4js.configure(
|
log4js.configure(
|
||||||
{ appenders: { "console": { type: "console" }},
|
{
|
||||||
|
appenders: { "console": { type: "console" }},
|
||||||
categories: {
|
categories: {
|
||||||
"default": { level: "PICKLES" }
|
"default": { level: "PICKLES" }
|
||||||
}
|
}
|
||||||
@@ -128,7 +134,8 @@ describe('../lib/log4js', function() {
|
|||||||
it('should complain if a category specifies an appender that does not exist', function() {
|
it('should complain if a category specifies an appender that does not exist', function() {
|
||||||
(function() {
|
(function() {
|
||||||
log4js.configure(
|
log4js.configure(
|
||||||
{ appenders: { "console": { type: "console" }},
|
{
|
||||||
|
appenders: { "console": { type: "console" }},
|
||||||
categories: {
|
categories: {
|
||||||
"default": { level: "DEBUG", appenders: [ "cheese" ] }
|
"default": { level: "DEBUG", appenders: [ "cheese" ] }
|
||||||
}
|
}
|
||||||
@@ -212,8 +219,8 @@ describe('../lib/log4js', function() {
|
|||||||
it('should read config from a file', function() {
|
it('should read config from a file', function() {
|
||||||
var events = [], log4js_sandbox = sandbox.require(
|
var events = [], log4js_sandbox = sandbox.require(
|
||||||
'../lib/log4js',
|
'../lib/log4js',
|
||||||
{ requires:
|
{
|
||||||
{
|
requires: {
|
||||||
'cheese': {
|
'cheese': {
|
||||||
configure: function() {
|
configure: function() {
|
||||||
return function(event) { events.push(event); };
|
return function(event) { events.push(event); };
|
||||||
@@ -235,8 +242,8 @@ describe('../lib/log4js', function() {
|
|||||||
, noisyLogger
|
, noisyLogger
|
||||||
, log4js_sandbox = sandbox.require(
|
, log4js_sandbox = sandbox.require(
|
||||||
'../lib/log4js',
|
'../lib/log4js',
|
||||||
{ requires:
|
{
|
||||||
{
|
requires: {
|
||||||
'cheese': {
|
'cheese': {
|
||||||
configure: function() {
|
configure: function() {
|
||||||
return function(event) { events.push(event); };
|
return function(event) { events.push(event); };
|
||||||
@@ -264,8 +271,8 @@ describe('../lib/log4js', function() {
|
|||||||
var events = []
|
var events = []
|
||||||
, log4js_sandbox = sandbox.require(
|
, log4js_sandbox = sandbox.require(
|
||||||
'../lib/log4js',
|
'../lib/log4js',
|
||||||
{ requires:
|
{
|
||||||
{
|
requires: {
|
||||||
'cheese': {
|
'cheese': {
|
||||||
configure: function() {
|
configure: function() {
|
||||||
return function(event) { events.push(event); };
|
return function(event) { events.push(event); };
|
||||||
|
|||||||
@@ -73,14 +73,14 @@ describe('../../lib/streams/BaseRollingFileStream', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not want to roll', function() {
|
it('should not want to roll', function() {
|
||||||
stream.shouldRoll().should.be.false;
|
stream.shouldRoll().should.eql(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not roll', function() {
|
it('should not roll', function() {
|
||||||
var cbCalled = false;
|
var cbCalled = false;
|
||||||
//just calls the callback straight away, no async calls
|
//just calls the callback straight away, no async calls
|
||||||
stream.roll('basetest.log', function() { cbCalled = true; });
|
stream.roll('basetest.log', function() { cbCalled = true; });
|
||||||
cbCalled.should.be.true;
|
cbCalled.should.eql(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -178,14 +178,19 @@ describe('DateRollingFileStream', function() {
|
|||||||
var stream;
|
var stream;
|
||||||
|
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
testTime = new Date(2012, 8, 12, 0, 10, 12),
|
testTime = new Date(2012, 8, 12, 0, 10, 12);
|
||||||
stream = new DateRollingFileStream(
|
remove(
|
||||||
__dirname + '/test-date-rolling-file-stream-pattern',
|
__dirname + '/test-date-rolling-file-stream-pattern.2012-09-12',
|
||||||
'.yyyy-MM-dd',
|
function() {
|
||||||
{ alwaysIncludePattern: true },
|
stream = new DateRollingFileStream(
|
||||||
now
|
__dirname + '/test-date-rolling-file-stream-pattern',
|
||||||
|
'.yyyy-MM-dd',
|
||||||
|
{ alwaysIncludePattern: true },
|
||||||
|
now
|
||||||
|
);
|
||||||
|
stream.write("First message\n", 'utf8', done);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
stream.write("First message\n", 'utf8', done);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function(done) {
|
after(function(done) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ if (semver.satisfies(process.version, '>=0.10.0')) {
|
|||||||
RollingFileStream = require('../../lib/streams').RollingFileStream;
|
RollingFileStream = require('../../lib/streams').RollingFileStream;
|
||||||
|
|
||||||
function remove(filename, cb) {
|
function remove(filename, cb) {
|
||||||
fs.unlink(filename, function() { cb(); });
|
fs.unlink(filename, function(err) { cb(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function create(filename, cb) {
|
function create(filename, cb) {
|
||||||
|
|||||||
Reference in New Issue
Block a user