Merge pull request #265 from 3rd-Eden/master

Better naming in the logging
This commit is contained in:
Guillermo Rauch
2011-06-22 01:25:30 -07:00
8 changed files with 67 additions and 10 deletions

View File

@@ -79,6 +79,7 @@ function Manager (server) {
, 'browser client': true
, 'browser client minification': false
, 'browser client etag': false
, 'browser client handler': false
};
// reset listeners

View File

@@ -33,6 +33,14 @@ function FlashSocket () {
FlashSocket.prototype.__proto__ = WebSocket.prototype;
/**
* Transport name
*
* @api public
*/
FlashSocket.prototype.name = 'flashsocket';
/**
* Listens for new configuration changes of the Manager
* this way we can enable and disable the flash server.

View File

@@ -33,6 +33,14 @@ function HTMLFile (mng, data) {
HTMLFile.prototype.__proto__ = HTTPTransport.prototype;
/**
* Transport name
*
* @api public
*/
HTMLFile.prototype.name = 'htmlfile';
/**
* Handles the request.
*
@@ -70,5 +78,5 @@ HTMLFile.prototype.write = function (data) {
this.drained = true;
}
this.log.debug('htmlfile writing', data);
this.log.debug(this.name + ' writing', data);
};

View File

@@ -35,6 +35,14 @@ function HTTPPolling (mng, data) {
HTTPPolling.prototype.__proto__ = HTTPTransport.prototype;
/**
* Transport name
*
* @api public
*/
HTTPPolling.prototype.name = 'httppolling';
/**
* Removes heartbeat timeouts for polling.
*/
@@ -56,8 +64,8 @@ HTTPPolling.prototype.handleRequest = function (req) {
var self = this;
this.pollTimeout = setTimeout(function () {
self.packet({ type: 'noop' });
self.log.debug('polling closed due to exceeded duration');
self.close();
self.log.debug(self.name + ' closed due to exceeded duration');
}, this.manager.get('polling duration') * 1000);
this.log.debug('setting poll timeout');

View File

@@ -35,6 +35,14 @@ function HTTPTransport (mng, data) {
HTTPTransport.prototype.__proto__ = Transport.prototype;
/**
* Transport name
*
* @api public
*/
HTTPTransport.prototype.name = 'httptransport';
/**
* Handles a request.
*
@@ -85,7 +93,7 @@ HTTPTransport.prototype.onData = function (data) {
var messages = parser.decodePayload(data);
for (var i = 0, l = messages.length; i < l; i++) {
this.log.debug('xhr received data packet', data);
this.log.debug(this.name + ' received data packet', data);
this.onMessage(messages[i]);
}
};

View File

@@ -40,6 +40,14 @@ function JSONPPolling (mng, data) {
JSONPPolling.prototype.__proto__ = HTTPPolling.prototype;
/**
* Transport name
*
* @api public
*/
JSONPPolling.prototype.name = 'jsonppolling';
/**
* Make sure POST are decoded.
*/
@@ -65,5 +73,5 @@ JSONPPolling.prototype.doWrite = function (data) {
});
this.response.write(data);
this.log.debug('json-p writing', data);
this.log.debug(this.name + ' writing', data);
};

View File

@@ -33,7 +33,7 @@ function WebSocket (mng, data) {
this.parser = new Parser();
this.parser.on('data', function (packet) {
self.log.debug('websocket received data packet', packet);
self.log.debug(self.name + ' received data packet', packet);
self.onMessage(parser.decodePacket(packet));
});
this.parser.on('close', function () {
@@ -52,6 +52,14 @@ function WebSocket (mng, data) {
WebSocket.prototype.__proto__ = Transport.prototype;
/**
* Transport name
*
* @api public
*/
WebSocket.prototype.name = 'websocket';
/**
* Called when the socket connects.
*
@@ -67,7 +75,7 @@ WebSocket.prototype.onSocketConnect = function () {
this.buffered = [];
if (this.req.headers.upgrade !== 'WebSocket') {
this.log.warn('WebSocket connection invalid');
this.log.warn(this.name + ' connection invalid');
this.end();
return;
}
@@ -180,7 +188,7 @@ WebSocket.prototype.write = function (data) {
this.end();
}
this.log.debug('websocket writing', data);
this.log.debug(this.name + ' writing', data);
}
};
@@ -217,7 +225,7 @@ WebSocket.prototype.proveReception = function (headers) {
, spaces = k.replace(/[^ ]/g, '').length;
if (spaces === 0 || n % spaces !== 0){
self.log.warn('Invalid WebSocket key: "' + k + '".');
self.log.warn('Invalid ' + self.name + ' key: "' + k + '".');
self.end();
return false;
}

View File

@@ -33,6 +33,14 @@ function XHRPolling (mng, data) {
XHRPolling.prototype.__proto__ = HTTPPolling.prototype;
/**
* Transport name
*
* @api public
*/
XHRPolling.prototype.name = 'xhrpolling';
/**
* Frames data prior to write.
*
@@ -60,5 +68,5 @@ XHRPolling.prototype.doWrite = function (data) {
this.response.writeHead(200, headers);
this.response.write(data);
this.log.debug('xhr-polling writing', data);
this.log.debug(this.name + ' writing', data);
};