Browse Source

better debug messages in net and tls

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
a48a075535
  1. 8
      lib/net.js
  2. 15
      lib/tls.js

8
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));

15
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);

Loading…
Cancel
Save