cleanup debug() usage

This commit is contained in:
Feross Aboukhadijeh 2014-08-02 14:41:04 -07:00
parent 789e3bd2a4
commit ab32d5e7a1
2 changed files with 13 additions and 13 deletions

View File

@ -48,7 +48,7 @@ function Client (peerId, port, torrent, opts) {
self._numWant = self._opts.numWant || 50 self._numWant = self._opts.numWant || 50
self._intervalMs = self._opts.interval || (30 * 60 * 1000) // default: 30 minutes self._intervalMs = self._opts.interval || (30 * 60 * 1000) // default: 30 minutes
debug('new tracker client for ' + self._infoHash.toString('hex')) debug('new client %s', self._infoHash.toString('hex'))
if (typeof torrent.announce === 'string') { if (typeof torrent.announce === 'string') {
// magnet-uri returns a string if the magnet uri only contains one 'tr' parameter // magnet-uri returns a string if the magnet uri only contains one 'tr' parameter
@ -148,7 +148,7 @@ function Tracker (client, announceUrl, opts) {
self.client = client self.client = client
debug('new tracker for ' + announceUrl) debug('new tracker %s', 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
@ -166,7 +166,7 @@ Tracker.prototype.start = function (opts) {
opts = opts || {} opts = opts || {}
opts.event = 'started' opts.event = 'started'
debug('sent `start` to ' + self._announceUrl) debug('sent `start` %s', self._announceUrl)
self._announce(opts) self._announce(opts)
self.setInterval(self._intervalMs) // start announcing on intervals self.setInterval(self._intervalMs) // start announcing on intervals
} }
@ -176,7 +176,7 @@ Tracker.prototype.stop = function (opts) {
opts = opts || {} opts = opts || {}
opts.event = 'stopped' opts.event = 'stopped'
debug('sent `stop` to ' + self._announceUrl) debug('sent `stop` %s', self._announceUrl)
self._announce(opts) self._announce(opts)
self.setInterval(0) // stop announcing on intervals self.setInterval(0) // stop announcing on intervals
} }
@ -187,7 +187,7 @@ Tracker.prototype.complete = function (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) debug('sent `complete` %s', self._announceUrl)
self._announce(opts) self._announce(opts)
} }
@ -195,7 +195,7 @@ Tracker.prototype.update = function (opts) {
var self = this var self = this
opts = opts || {} opts = opts || {}
debug('sent `update` to ' + self._announceUrl) debug('sent `update` %s', self._announceUrl)
self._announce(opts) self._announce(opts)
} }
@ -229,12 +229,12 @@ Tracker.prototype.scrape = function () {
self._scrapeUrl = self._scrapeUrl || getScrapeUrl(self._announceUrl) self._scrapeUrl = self._scrapeUrl || getScrapeUrl(self._announceUrl)
if (!self._scrapeUrl) { if (!self._scrapeUrl) {
debug('scrape not supported by ' + self._announceUrl) debug('scrape not supported %s', self._announceUrl)
self.client.emit('error', new Error('scrape not supported for announceUrl ' + self._announceUrl)) self.client.emit('error', new Error('scrape not supported for announceUrl ' + self._announceUrl))
return return
} }
debug('sent `scrape` to ' + self._announceUrl) debug('sent `scrape` %s', self._announceUrl)
self._requestImpl(self._scrapeUrl, { _scrape: true }) self._requestImpl(self._scrapeUrl, { _scrape: true })
} }

View File

@ -235,7 +235,7 @@ Server.prototype._onHttpRequest = function (req, res) {
response['warning message'] = warning response['warning message'] = warning
} }
res.end(bencode.encode(response)) res.end(bencode.encode(response))
debug('sent response ' + response) debug('sent response %s', response)
} else if (s[0] === '/scrape') { // unofficial scrape message } else if (s[0] === '/scrape') { // unofficial scrape message
if (typeof params.info_hash === 'string') { if (typeof params.info_hash === 'string') {
@ -270,14 +270,14 @@ Server.prototype._onHttpRequest = function (req, res) {
}) })
res.end(bencode.encode(response)) res.end(bencode.encode(response))
debug('sent response ' + response) debug('sent response %s', response)
} else { } else {
error('only /announce and /scrape are valid endpoints') error('only /announce and /scrape are valid endpoints')
} }
function error (message) { function error (message) {
debug('sent error ' + message) debug('sent error %s', message)
res.end(bencode.encode({ res.end(bencode.encode({
'failure reason': message 'failure reason': message
})) }))
@ -447,7 +447,7 @@ Server.prototype._onUdpRequest = function (msg, rinfo) {
} }
function send (buf) { function send (buf) {
debug('sent response ' + buf) debug('sent response %s', buf.toString('hex'))
socket.send(buf, 0, buf.length, rinfo.port, rinfo.address, function () { socket.send(buf, 0, buf.length, rinfo.port, rinfo.address, function () {
try { try {
socket.close() socket.close()
@ -456,7 +456,7 @@ Server.prototype._onUdpRequest = function (msg, rinfo) {
} }
function error (message) { function error (message) {
debug('sent error ' + message) debug('sent error %s', message)
send(Buffer.concat([ send(Buffer.concat([
common.toUInt32(common.ACTIONS.ERROR), common.toUInt32(common.ACTIONS.ERROR),
common.toUInt32(transactionId || 0), common.toUInt32(transactionId || 0),