Skip to content

Commit ab32d5e

Browse files
committed
cleanup debug() usage
1 parent 789e3bd commit ab32d5e

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

client.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function Client (peerId, port, torrent, opts) {
4848
self._numWant = self._opts.numWant || 50
4949
self._intervalMs = self._opts.interval || (30 * 60 * 1000) // default: 30 minutes
5050

51-
debug('new tracker client for ' + self._infoHash.toString('hex'))
51+
debug('new client %s', self._infoHash.toString('hex'))
5252

5353
if (typeof torrent.announce === 'string') {
5454
// magnet-uri returns a string if the magnet uri only contains one 'tr' parameter
@@ -148,7 +148,7 @@ function Tracker (client, announceUrl, opts) {
148148

149149
self.client = client
150150

151-
debug('new tracker for ' + announceUrl)
151+
debug('new tracker %s', announceUrl)
152152

153153
self._announceUrl = announceUrl
154154
self._intervalMs = self.client._intervalMs // use client interval initially
@@ -166,7 +166,7 @@ Tracker.prototype.start = function (opts) {
166166
opts = opts || {}
167167
opts.event = 'started'
168168

169-
debug('sent `start` to ' + self._announceUrl)
169+
debug('sent `start` %s', self._announceUrl)
170170
self._announce(opts)
171171
self.setInterval(self._intervalMs) // start announcing on intervals
172172
}
@@ -176,7 +176,7 @@ Tracker.prototype.stop = function (opts) {
176176
opts = opts || {}
177177
opts.event = 'stopped'
178178

179-
debug('sent `stop` to ' + self._announceUrl)
179+
debug('sent `stop` %s', self._announceUrl)
180180
self._announce(opts)
181181
self.setInterval(0) // stop announcing on intervals
182182
}
@@ -187,15 +187,15 @@ Tracker.prototype.complete = function (opts) {
187187
opts.event = 'completed'
188188
opts.downloaded = opts.downloaded || self.torrentLength || 0
189189

190-
debug('sent `complete` to ' + self._announceUrl)
190+
debug('sent `complete` %s', self._announceUrl)
191191
self._announce(opts)
192192
}
193193

194194
Tracker.prototype.update = function (opts) {
195195
var self = this
196196
opts = opts || {}
197197

198-
debug('sent `update` to ' + self._announceUrl)
198+
debug('sent `update` %s', self._announceUrl)
199199
self._announce(opts)
200200
}
201201

@@ -229,12 +229,12 @@ Tracker.prototype.scrape = function () {
229229
self._scrapeUrl = self._scrapeUrl || getScrapeUrl(self._announceUrl)
230230

231231
if (!self._scrapeUrl) {
232-
debug('scrape not supported by ' + self._announceUrl)
232+
debug('scrape not supported %s', self._announceUrl)
233233
self.client.emit('error', new Error('scrape not supported for announceUrl ' + self._announceUrl))
234234
return
235235
}
236236

237-
debug('sent `scrape` to ' + self._announceUrl)
237+
debug('sent `scrape` %s', self._announceUrl)
238238
self._requestImpl(self._scrapeUrl, { _scrape: true })
239239
}
240240

server.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Server.prototype._onHttpRequest = function (req, res) {
235235
response['warning message'] = warning
236236
}
237237
res.end(bencode.encode(response))
238-
debug('sent response ' + response)
238+
debug('sent response %s', response)
239239

240240
} else if (s[0] === '/scrape') { // unofficial scrape message
241241
if (typeof params.info_hash === 'string') {
@@ -270,14 +270,14 @@ Server.prototype._onHttpRequest = function (req, res) {
270270
})
271271

272272
res.end(bencode.encode(response))
273-
debug('sent response ' + response)
273+
debug('sent response %s', response)
274274

275275
} else {
276276
error('only /announce and /scrape are valid endpoints')
277277
}
278278

279279
function error (message) {
280-
debug('sent error ' + message)
280+
debug('sent error %s', message)
281281
res.end(bencode.encode({
282282
'failure reason': message
283283
}))
@@ -447,7 +447,7 @@ Server.prototype._onUdpRequest = function (msg, rinfo) {
447447
}
448448

449449
function send (buf) {
450-
debug('sent response ' + buf)
450+
debug('sent response %s', buf.toString('hex'))
451451
socket.send(buf, 0, buf.length, rinfo.port, rinfo.address, function () {
452452
try {
453453
socket.close()
@@ -456,7 +456,7 @@ Server.prototype._onUdpRequest = function (msg, rinfo) {
456456
}
457457

458458
function error (message) {
459-
debug('sent error ' + message)
459+
debug('sent error %s', message)
460460
send(Buffer.concat([
461461
common.toUInt32(common.ACTIONS.ERROR),
462462
common.toUInt32(transactionId || 0),

0 commit comments

Comments
 (0)