got rid of the __preLog4js stuff from the console.log replacement
This commit is contained in:
parent
cff20b99e3
commit
53367785b4
@ -357,28 +357,30 @@ function configure (configurationFileOrObject, options) {
|
||||
configureOnceOff(config);
|
||||
}
|
||||
|
||||
var originalConsoleFunctions = {
|
||||
log: console.log,
|
||||
debug: console.debug,
|
||||
info: console.info,
|
||||
warn: console.warn,
|
||||
error: console.error
|
||||
};
|
||||
|
||||
function replaceConsole(logger) {
|
||||
function replaceWith(fn) {
|
||||
return function() {
|
||||
fn.apply(logger, arguments);
|
||||
}
|
||||
}
|
||||
if (console['_preLog4js_log'] === undefined) {
|
||||
logger = logger || getLogger("console");
|
||||
['log','debug','info','warn','error'].forEach(function (item) {
|
||||
console['_preLog4js_'+item] = console[item];
|
||||
console[item] = replaceWith(item === 'log' ? logger.info : logger[item]);
|
||||
});
|
||||
}
|
||||
logger = logger || getLogger("console");
|
||||
['log','debug','info','warn','error'].forEach(function (item) {
|
||||
console[item] = replaceWith(item === 'log' ? logger.info : logger[item]);
|
||||
});
|
||||
}
|
||||
|
||||
function restoreConsole() {
|
||||
if (console['_preLog4js_log']) {
|
||||
['log', 'debug', 'info', 'warn', 'error'].forEach(function (item) {
|
||||
console[item] = console['_preLog4js_'+item];
|
||||
delete console['_preLog4js_'+item];
|
||||
});
|
||||
}
|
||||
['log', 'debug', 'info', 'warn', 'error'].forEach(function (item) {
|
||||
console[item] = originalConsoleFunctions[item];
|
||||
});
|
||||
}
|
||||
|
||||
function loadAppender(appender) {
|
||||
|
@ -1,12 +1,12 @@
|
||||
var util = require('util'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
events = require('events'),
|
||||
var util = require('util'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
events = require('events'),
|
||||
async = require('async');
|
||||
|
||||
function debug(message) {
|
||||
// util.debug(message);
|
||||
console.log(message);
|
||||
util.debug(message);
|
||||
// console.log(message);
|
||||
}
|
||||
|
||||
function BufferedWriteStream(stream) {
|
||||
@ -265,4 +265,4 @@ RollingFileStream.prototype.roll = function(filename, callback) {
|
||||
|
||||
exports.BaseRollingFileStream = BaseRollingFileStream;
|
||||
exports.RollingFileStream = RollingFileStream;
|
||||
exports.BufferedWriteStream = BufferedWriteStream;
|
||||
exports.BufferedWriteStream = BufferedWriteStream;
|
||||
|
@ -20,6 +20,7 @@ vows.describe('log4js fileAppender').addBatch({
|
||||
var that = this, testFile = __dirname + '/fa-default-test.log'
|
||||
, logger = log4js.getLogger('default-settings');
|
||||
remove(testFile);
|
||||
log4js.clearAppenders();
|
||||
log4js.addAppender(log4js.fileAppender(testFile), 'default-settings');
|
||||
|
||||
logger.info("This should be in the file.");
|
||||
@ -43,6 +44,7 @@ vows.describe('log4js fileAppender').addBatch({
|
||||
remove(testFile);
|
||||
remove(testFile + '.1');
|
||||
//log file of 100 bytes maximum, no backups
|
||||
log4js.clearAppenders();
|
||||
log4js.addAppender(log4js.fileAppender(testFile, log4js.layouts.basicLayout, 100, 0), 'max-file-size');
|
||||
logger.info("This is the first log message.");
|
||||
logger.info("This is an intermediate log message.");
|
||||
@ -76,6 +78,7 @@ vows.describe('log4js fileAppender').addBatch({
|
||||
remove(testFile+'.2');
|
||||
|
||||
//log file of 50 bytes maximum, 2 backups
|
||||
log4js.clearAppenders();
|
||||
log4js.addAppender(log4js.fileAppender(testFile, log4js.layouts.basicLayout, 50, 2), 'max-file-size-backups');
|
||||
logger.info("This is the first log message.");
|
||||
logger.info("This is the second log message.");
|
||||
@ -146,4 +149,4 @@ vows.describe('log4js fileAppender').addBatch({
|
||||
}
|
||||
}
|
||||
|
||||
}).export(module);
|
||||
}).export(module);
|
||||
|
Loading…
Reference in New Issue
Block a user