From e58cf201cab1240e94beb36d142f1744971f6cb9 Mon Sep 17 00:00:00 2001 From: Gary Steven Date: Sat, 30 Mar 2013 03:23:58 -0700 Subject: [PATCH] Updated for Node 0.10.x net.createServer no longer emits 'connect' event --- lib/appenders/multiprocess.js | 37 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/lib/appenders/multiprocess.js b/lib/appenders/multiprocess.js index a698097..3d0f2bf 100644 --- a/lib/appenders/multiprocess.js +++ b/lib/appenders/multiprocess.js @@ -38,31 +38,30 @@ function logServer(config) { var actualAppender = config.actualAppender, server = net.createServer(function serverCreated(clientSocket) { clientSocket.setEncoding('utf8'); - clientSocket.on('connect', function clientConnected() { - var logMessage = ''; + var logMessage = ''; - function logTheMessage(msg) { - if (logMessage.length > 0) { - actualAppender(deserializeLoggingEvent(clientSocket, msg)); - } + function logTheMessage(msg) { + if (logMessage.length > 0) { + actualAppender(deserializeLoggingEvent(clientSocket, msg)); } + } - function chunkReceived(chunk) { - var event; - logMessage += chunk || ''; - if (logMessage.indexOf(END_MSG) > -1) { - event = logMessage.substring(0, logMessage.indexOf(END_MSG)); - logTheMessage(event); - logMessage = logMessage.substring(event.length + END_MSG.length) || ''; - //check for more, maybe it was a big chunk - chunkReceived(); - } + function chunkReceived(chunk) { + var event; + logMessage += chunk || ''; + if (logMessage.indexOf(END_MSG) > -1) { + event = logMessage.substring(0, logMessage.indexOf(END_MSG)); + logTheMessage(event); + logMessage = logMessage.substring(event.length + END_MSG.length) || ''; + //check for more, maybe it was a big chunk + chunkReceived(); } + } - clientSocket.on('data', chunkReceived); - clientSocket.on('end', chunkReceived); - }); + clientSocket.on('data', chunkReceived); + clientSocket.on('end', chunkReceived); }); + server.listen(config.loggerPort || 5000, config.loggerHost || 'localhost'); return actualAppender;