Permalink
Browse files

fix for issue #100, multiprocess appender and logLevelFilter don't pl…

…ay nicely
  • Loading branch information...
1 parent 4739c65 commit a9307fd6dababf8a4dbd7e8317c7fd64b57ce16e Gareth Jones committed Nov 9, 2012
Showing with 8 additions and 13 deletions.
  1. +4 −9 lib/appenders/multiprocess.js
  2. +1 −1 package.json
  3. +3 −3 test/multiprocess-test.js
@@ -16,20 +16,15 @@ function logServer(config) {
function deserializeLoggingEvent(clientSocket, msg) {
var loggingEvent;
try {
- loggingEvent = JSON.parse(msg);
- loggingEvent.startTime = new Date(loggingEvent.startTime);
- loggingEvent.level.toString = function levelToString() {
- return loggingEvent.level.levelStr;
- };
+ loggingEvent = JSON.parse(msg);
+ loggingEvent.startTime = new Date(loggingEvent.startTime);
+ loggingEvent.level = log4js.levels.toLevel(loggingEvent.level.levelStr);
} catch (e) {
// JSON.parse failed, just log the contents probably a naughty.
loggingEvent = {
startTime: new Date(),
categoryName: 'log4js',
- level: { toString: function () {
- return 'ERROR';
- }
- },
+ level: log4js.levels.ERROR,
data: [ 'Unable to parse log:', msg ]
};
}
View
@@ -1,6 +1,6 @@
{
"name": "log4js",
- "version": "0.5.4",
+ "version": "0.5.5",
"description": "Port of Log4js to work with node.",
"keywords": [
"logging",
@@ -181,14 +181,14 @@ vows.describe('Multiprocess Appender').addBatch({
},
'when a client connects': {
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['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(10));
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__');
return net;
},

0 comments on commit a9307fd

Please sign in to comment.