From c52169d13673cf7279ed15fd2ae5af5b415bc9e7 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 6 Jun 2014 00:23:02 -0700 Subject: [PATCH] add debug messages --- index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 441239c..6b6903f 100644 --- a/index.js +++ b/index.js @@ -36,6 +36,7 @@ inherits(Tracker, EventEmitter) * @param {Object} opts optional options */ function Tracker (client, announceUrl, opts) { + debug('new tracker for ' + announceUrl) var self = this EventEmitter.call(self) self._opts = opts || {} @@ -51,9 +52,11 @@ function Tracker (client, announceUrl, opts) { } else { self._requestImpl = self._requestHttp } + } Tracker.prototype.start = function (opts) { + debug('sent `start` to ' + self._announceUrl) var self = this opts = opts || {} opts.event = 'started' @@ -63,6 +66,7 @@ Tracker.prototype.start = function (opts) { } Tracker.prototype.stop = function (opts) { + debug('sent `stop` to ' + self._announceUrl) var self = this opts = opts || {} opts.event = 'stopped' @@ -72,6 +76,7 @@ Tracker.prototype.stop = function (opts) { } Tracker.prototype.complete = function (opts) { + debug('sent `complete` to ' + self._announceUrl) var self = this opts = opts || {} opts.event = 'completed' @@ -80,6 +85,7 @@ Tracker.prototype.complete = function (opts) { } Tracker.prototype.update = function (opts) { + debug('sent `update` to ' + self._announceUrl) var self = this opts = opts || {} self._request(opts) @@ -98,10 +104,13 @@ Tracker.prototype.scrape = function (opts) { } if (!self._scrapeUrl) { + debug('scrape not supported by ' + self._announceUrl) self.client.emit('error', new Error('scrape not supported for announceUrl ' + self._announceUrl)) return } + debug('sent `scrape` to ' + self._announceUrl) + opts = extend({ info_hash: bytewiseEncodeURIComponent(self.client._infoHash) }, opts) @@ -428,7 +437,6 @@ function Client (peerId, port, torrent, opts) { torrent.announce = [torrent.announce] } self._trackers = torrent.announce.map(function (announceUrl) { - debug('creating tracker for ' + announceUrl) return new Tracker(self, announceUrl, self._opts) }) }