fix debug usage

This commit is contained in:
Feross Aboukhadijeh 2014-06-06 00:25:51 -07:00
parent c52169d136
commit cf074e12a8

View File

@ -36,13 +36,14 @@ inherits(Tracker, EventEmitter)
* @param {Object} opts optional options * @param {Object} opts optional options
*/ */
function Tracker (client, announceUrl, opts) { function Tracker (client, announceUrl, opts) {
debug('new tracker for ' + announceUrl)
var self = this var self = this
EventEmitter.call(self) EventEmitter.call(self)
self._opts = opts || {} self._opts = opts || {}
self.client = client self.client = client
debug('new tracker for ' + announceUrl)
self._announceUrl = announceUrl self._announceUrl = announceUrl
self._intervalMs = self.client._intervalMs // use client interval initially self._intervalMs = self.client._intervalMs // use client interval initially
self._interval = null self._interval = null
@ -56,38 +57,40 @@ function Tracker (client, announceUrl, opts) {
} }
Tracker.prototype.start = function (opts) { Tracker.prototype.start = function (opts) {
debug('sent `start` to ' + self._announceUrl)
var self = this var self = this
opts = opts || {} opts = opts || {}
opts.event = 'started' opts.event = 'started'
self._request(opts)
debug('sent `start` to ' + self._announceUrl)
self._request(opts)
self.setInterval(self._intervalMs) // start announcing on intervals self.setInterval(self._intervalMs) // start announcing on intervals
} }
Tracker.prototype.stop = function (opts) { Tracker.prototype.stop = function (opts) {
debug('sent `stop` to ' + self._announceUrl)
var self = this var self = this
opts = opts || {} opts = opts || {}
opts.event = 'stopped' opts.event = 'stopped'
self._request(opts)
debug('sent `stop` to ' + self._announceUrl)
self._request(opts)
self.setInterval(0) // stop announcing on intervals self.setInterval(0) // stop announcing on intervals
} }
Tracker.prototype.complete = function (opts) { Tracker.prototype.complete = function (opts) {
debug('sent `complete` to ' + self._announceUrl)
var self = this var self = this
opts = opts || {} opts = opts || {}
opts.event = 'completed' opts.event = 'completed'
opts.downloaded = opts.downloaded || self.torrentLength || 0 opts.downloaded = opts.downloaded || self.torrentLength || 0
debug('sent `complete` to ' + self._announceUrl)
self._request(opts) self._request(opts)
} }
Tracker.prototype.update = function (opts) { Tracker.prototype.update = function (opts) {
debug('sent `update` to ' + self._announceUrl)
var self = this var self = this
opts = opts || {} opts = opts || {}
debug('sent `update` to ' + self._announceUrl)
self._request(opts) self._request(opts)
} }