Merge branch 'master' of https://github.com/dsn/log4js-node into dsn-master
This commit is contained in:
commit
73437ecb40
@ -38,31 +38,30 @@ function logServer(config) {
|
|||||||
var actualAppender = config.actualAppender,
|
var actualAppender = config.actualAppender,
|
||||||
server = net.createServer(function serverCreated(clientSocket) {
|
server = net.createServer(function serverCreated(clientSocket) {
|
||||||
clientSocket.setEncoding('utf8');
|
clientSocket.setEncoding('utf8');
|
||||||
clientSocket.on('connect', function clientConnected() {
|
var logMessage = '';
|
||||||
var logMessage = '';
|
|
||||||
|
|
||||||
function logTheMessage(msg) {
|
function logTheMessage(msg) {
|
||||||
if (logMessage.length > 0) {
|
if (logMessage.length > 0) {
|
||||||
actualAppender(deserializeLoggingEvent(clientSocket, msg));
|
actualAppender(deserializeLoggingEvent(clientSocket, msg));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function chunkReceived(chunk) {
|
function chunkReceived(chunk) {
|
||||||
var event;
|
var event;
|
||||||
logMessage += chunk || '';
|
logMessage += chunk || '';
|
||||||
if (logMessage.indexOf(END_MSG) > -1) {
|
if (logMessage.indexOf(END_MSG) > -1) {
|
||||||
event = logMessage.substring(0, logMessage.indexOf(END_MSG));
|
event = logMessage.substring(0, logMessage.indexOf(END_MSG));
|
||||||
logTheMessage(event);
|
logTheMessage(event);
|
||||||
logMessage = logMessage.substring(event.length + END_MSG.length) || '';
|
logMessage = logMessage.substring(event.length + END_MSG.length) || '';
|
||||||
//check for more, maybe it was a big chunk
|
//check for more, maybe it was a big chunk
|
||||||
chunkReceived();
|
chunkReceived();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clientSocket.on('data', chunkReceived);
|
clientSocket.on('data', chunkReceived);
|
||||||
clientSocket.on('end', chunkReceived);
|
clientSocket.on('end', chunkReceived);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(config.loggerPort || 5000, config.loggerHost || 'localhost');
|
server.listen(config.loggerPort || 5000, config.loggerHost || 'localhost');
|
||||||
|
|
||||||
return actualAppender;
|
return actualAppender;
|
||||||
|
Loading…
Reference in New Issue
Block a user