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