diff --git a/lib/net.js b/lib/net.js index 965d485207..43cfb0f74c 100644 --- a/lib/net.js +++ b/lib/net.js @@ -8,7 +8,7 @@ var kPoolSize = 40 * 1024; var debug; if (process.env.NODE_DEBUG && /net/.test(process.env.NODE_DEBUG)) { - debug = function(x) { util.error.apply(this, arguments); }; + debug = function(x) { console.error('NET:', x); }; } else { debug = function() { }; } @@ -431,8 +431,8 @@ Socket.prototype._writeOut = function(data, encoding, fd, cb) { return false; } - debug('wrote ' + bytesWritten + ' to socket. [fd, off, len] = ' + - JSON.stringify([this.fd, off, len]) + '\n'); + debug('wrote ' + bytesWritten + ' bytes to socket.') + debug('[fd, off, len] = ' + JSON.stringify([this.fd, off, len])); timers.active(this); @@ -635,6 +635,8 @@ Socket.prototype._onReadable = function() { var end = pool.used + bytesRead; pool.used += bytesRead; + debug('socket ' + self.fd + ' received ' + bytesRead + ' bytes'); + if (self._decoder) { // emit String var string = self._decoder.write(pool.slice(start, end)); diff --git a/lib/tls.js b/lib/tls.js index 100fd09f16..c12513e118 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -8,7 +8,7 @@ var assert = require('assert').ok; var debug; if (process.env.NODE_DEBUG && /tls/.test(process.env.NODE_DEBUG)) { - debug = function(a) { console.error("TLS: ", a); }; + debug = function(a) { console.error('TLS:', a); }; } else { debug = function() { }; } @@ -38,7 +38,12 @@ util.inherits(CryptoStream, stream.Stream); CryptoStream.prototype.write = function(data /* , encoding, cb */) { - debug('CryptoStream.prototype.write called with <<<<' + data.toString() + '>>>'); + if (this == this.pair.cleartext) { + debug('cleartext.write called with (((' + data.toString() + ')))'); + } else { + debug('encrypted.write called with ' + data.length + ' bytes'); + } + if (!this.writable) { throw new Error('CryptoStream is not writable'); } @@ -241,7 +246,11 @@ CryptoStream.prototype._push = function() { var chunk = pool.slice(0, bytesRead); - debug('emit "data" called with <<<<' + chunk.toString() + '>>>'); + if (this === this.pair.cleartext) { + debug('cleartext emit "data" called with (((' + chunk.toString() + ')))'); + } else { + debug('encrypted emit "data" with ' + bytesRead + ' bytes'); + } if (this._decoder) { var string = this._decoder.write(chunk);