fix for issue #100, multiprocess appender and logLevelFilter don't play nicely

This commit is contained in:
Gareth Jones 2012-11-09 16:02:16 +11:00
parent 4739c65c68
commit a9307fd6da
3 changed files with 8 additions and 13 deletions

View File

@ -16,20 +16,15 @@ function logServer(config) {
function deserializeLoggingEvent(clientSocket, msg) { function deserializeLoggingEvent(clientSocket, msg) {
var loggingEvent; var loggingEvent;
try { try {
loggingEvent = JSON.parse(msg); loggingEvent = JSON.parse(msg);
loggingEvent.startTime = new Date(loggingEvent.startTime); loggingEvent.startTime = new Date(loggingEvent.startTime);
loggingEvent.level.toString = function levelToString() { loggingEvent.level = log4js.levels.toLevel(loggingEvent.level.levelStr);
return loggingEvent.level.levelStr;
};
} catch (e) { } catch (e) {
// JSON.parse failed, just log the contents probably a naughty. // JSON.parse failed, just log the contents probably a naughty.
loggingEvent = { loggingEvent = {
startTime: new Date(), startTime: new Date(),
categoryName: 'log4js', categoryName: 'log4js',
level: { toString: function () { level: log4js.levels.ERROR,
return 'ERROR';
}
},
data: [ 'Unable to parse log:', msg ] data: [ 'Unable to parse log:', msg ]
}; };
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "log4js", "name": "log4js",
"version": "0.5.4", "version": "0.5.5",
"description": "Port of Log4js to work with node.", "description": "Port of Log4js to work with node.",
"keywords": [ "keywords": [
"logging", "logging",

View File

@ -181,14 +181,14 @@ vows.describe('Multiprocess Appender').addBatch({
}, },
'when a client connects': { 'when a client connects': {
topic: function(net) { topic: function(net) {
var logString = JSON.stringify({ level: 'DEBUG', data: ['some debug']}) + '__LOG4JS__'; var logString = JSON.stringify({ level: { level: 10000, levelStr: 'DEBUG' }, data: ['some debug']}) + '__LOG4JS__';
net.cbs['connect'](); net.cbs['connect']();
net.cbs['data'](JSON.stringify({ level: 'ERROR', data: ['an error message'] }) + '__LOG4JS__'); net.cbs['data'](JSON.stringify({ level: { level: 40000, levelStr: 'ERROR' }, data: ['an error message'] }) + '__LOG4JS__');
net.cbs['data'](logString.substring(0, 10)); net.cbs['data'](logString.substring(0, 10));
net.cbs['data'](logString.substring(10)); net.cbs['data'](logString.substring(10));
net.cbs['data'](logString + logString + logString); net.cbs['data'](logString + logString + logString);
net.cbs['end'](JSON.stringify({ level: 'FATAL', data: ["that's all folks"] }) + '__LOG4JS__'); net.cbs['end'](JSON.stringify({ level: { level: 50000, levelStr: 'FATAL' }, data: ["that's all folks"] }) + '__LOG4JS__');
net.cbs['data']('bad message__LOG4JS__'); net.cbs['data']('bad message__LOG4JS__');
return net; return net;
}, },