changes for node 0.1.30, tests run but don't pass yet

This commit is contained in:
csausdev
2010-02-22 20:09:56 +11:00
parent 15e9a30d05
commit f130b95b08
3 changed files with 14 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
var posix = require('posix'), sys = require('sys');
var fs = require('fs'), sys = require('sys');
var DEFAULT_CATEGORY = '[default]';
var ALL_CATEGORIES = '[all]';
@@ -146,13 +146,7 @@ var log4js = {
},
configure: function(configurationFile) {
var config;
posix
.cat(configurationFile)
.addCallback(
function(contents) { config = JSON.parse(contents); }
).wait();
var config = JSON.parse(fs.readFileSync(configurationFile));
configureAppenders(config.appenders);
configureLevels(config.levels);
},
@@ -382,16 +376,16 @@ consoleAppender = function (layout) {
fileAppender = function(file, layout) {
layout = layout || basicLayout;
file = file || "log4js.log";
//waits are generally bad, but we need
//syncs are generally bad, but we need
//the file to be open before we start doing any writing.
var logFile = posix.open(file, process.O_APPEND | process.O_WRONLY | process.O_CREAT, 0644).wait();
var logFile = fs.openSync(file, process.O_APPEND | process.O_WRONLY | process.O_CREAT, 0644);
//register ourselves as listeners for shutdown
//so that we can close the file.
//not entirely sure this is necessary, but still.
process.addListener("exit", function() { posix.close(logFile); });
process.addListener("exit", function() { fs.close(logFile); });
return function(loggingEvent) {
posix.write(logFile, layout(loggingEvent)+'\n', null, "utf-8");
fs.write(logFile, layout(loggingEvent)+'\n', null, "utf-8");
};
};