This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

better debug messages in net and tls

  • Loading branch information...
1 parent 56ab929 commit a48a0755358d322f4a593d09c331432c10a500bc @ry ry committed Feb 9, 2011
Showing with 17 additions and 6 deletions.
  1. +5 −3 lib/net.js
  2. +12 −3 lib/tls.js
View
@@ -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));
View
@@ -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);

0 comments on commit a48a075

Please sign in to comment.