fixed to work with node 0.5.x
This commit is contained in:
parent
53a481d4da
commit
12e71bda4e
@ -1,5 +1,7 @@
|
||||
# log4js-node
|
||||
|
||||
NOTE: v0.3.8 of log4js is the last that will work with node versions older than 0.4. To use v0.3.9 you will need node 0.4 or later.
|
||||
|
||||
This is a conversion of the [log4js](http://log4js.berlios.de/index.html)
|
||||
framework to work with [node](http://nodejs.org). I've mainly stripped out the browser-specific code
|
||||
and tidied up some of the javascript. It includes a basic file logger, with log rolling based on file size, and also replaces node's console.log functions.
|
||||
|
@ -249,22 +249,15 @@ function getDefaultLogger () {
|
||||
}
|
||||
|
||||
function findConfiguration() {
|
||||
//add current directory onto the list of configPaths
|
||||
var paths = ['.'].concat(require.paths);
|
||||
//add this module's directory to the end of the list, so that we pick up the default config
|
||||
paths.push(__dirname);
|
||||
var pathsWithConfig = paths.filter( function (pathToCheck) {
|
||||
try {
|
||||
fs.statSync(path.join(pathToCheck, "log4js.json"));
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (pathsWithConfig.length > 0) {
|
||||
return path.join(pathsWithConfig[0], 'log4js.json');
|
||||
var path;
|
||||
try {
|
||||
path = require.resolve('log4js.json');
|
||||
} catch (e) {
|
||||
//file not found. default to the one in the log4js module.
|
||||
path = __dirname + '/log4js.json';
|
||||
}
|
||||
return undefined;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
function loadConfigurationFile(filename) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "log4js",
|
||||
"version": "0.3.8",
|
||||
"version": "0.3.9",
|
||||
"description": "Port of Log4js to work with node.",
|
||||
"keywords": [
|
||||
"logging",
|
||||
@ -13,7 +13,7 @@
|
||||
"bugs": {
|
||||
"web": "http://github.com/csausdev/log4js-node/issues"
|
||||
},
|
||||
"engines": [ "node >=0.1.100" ],
|
||||
"engines": [ "node >=0.4" ],
|
||||
"scripts": {
|
||||
"test": "vows test/*.js"
|
||||
},
|
||||
|
@ -264,7 +264,7 @@ vows.describe('log4js').addBatch({
|
||||
|
||||
'default setup': {
|
||||
topic: function() {
|
||||
var pathsChecked = [],
|
||||
var pathLoaded,
|
||||
appenderEvent,
|
||||
logger,
|
||||
modulePath = require('path').normalize(__dirname + '/../lib/log4js.json'),
|
||||
@ -273,17 +273,9 @@ vows.describe('log4js').addBatch({
|
||||
return require('fs').readdirSync(dir);
|
||||
},
|
||||
readFileSync: function (file, encoding) {
|
||||
assert.equal(file, modulePath);
|
||||
pathLoaded = file;
|
||||
assert.equal(encoding, 'utf8');
|
||||
return '{ "appenders" : [ { "type": "console", "layout": { "type": "messagePassThrough" }} ] }';
|
||||
},
|
||||
statSync: function (path) {
|
||||
pathsChecked.push(path);
|
||||
if (path === modulePath) {
|
||||
return true;
|
||||
} else {
|
||||
throw new Error("no such file");
|
||||
}
|
||||
}
|
||||
},
|
||||
fakeConsole = {
|
||||
@ -307,18 +299,12 @@ vows.describe('log4js').addBatch({
|
||||
|
||||
logger = log4js.getLogger('a-test');
|
||||
logger.debug("this is a test");
|
||||
return [ pathsChecked, appenderEvent, modulePath ];
|
||||
return [ pathLoaded, appenderEvent, modulePath ];
|
||||
},
|
||||
|
||||
'should check current directory, require paths, and finally the module dir for log4js.json': function(args) {
|
||||
var pathsChecked = args[0];
|
||||
expectedPaths = ['log4js.json'].concat(
|
||||
require.paths.map(function(item) {
|
||||
return item + '/log4js.json';
|
||||
}),
|
||||
args[2]
|
||||
);
|
||||
assert.deepEqual(pathsChecked, expectedPaths);
|
||||
'should use require.resolve to find log4js.json': function(args) {
|
||||
var pathLoaded = args[0], modulePath = args[2];
|
||||
assert.equal(pathLoaded, modulePath);
|
||||
},
|
||||
|
||||
'should configure log4js from first log4js.json found': function(args) {
|
||||
|
Loading…
Reference in New Issue
Block a user