Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2017-02-03 03:06:41 +0300
committerFeross Aboukhadijeh <feross@feross.org>2017-02-03 03:06:41 +0300
commit4ca5c9afc34dce08b8e4b1d68fd33425218ac767 (patch)
tree94d0eca3465b4a4c0634683547c1468043ac7608 /lib
parent39d2f8ca59f9a29519727bd66b87c0b7b9930100 (diff)
include infoHash in torrent.js debug logs
Diffstat (limited to 'lib')
-rw-r--r--lib/torrent.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/torrent.js b/lib/torrent.js
index 093e6b5..a2c6c57 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -66,10 +66,8 @@ inherits(Torrent, EventEmitter)
function Torrent (torrentId, client, opts) {
EventEmitter.call(this)
+ this._debugId = 'unknown infohash'
this.client = client
- this._debugId = this.client.peerId.toString('hex').substring(0, 7)
-
- this._debug('new torrent')
this.announce = opts.announce
this.urlList = opts.urlList
@@ -124,6 +122,8 @@ function Torrent (torrentId, client, opts) {
this._fileModtimes = opts.fileModtimes
if (torrentId !== null) this._onTorrentId(torrentId)
+
+ this._debug('new torrent')
}
Object.defineProperty(Torrent.prototype, 'timeRemaining', {
@@ -226,6 +226,7 @@ Torrent.prototype._onTorrentId = function (torrentId) {
if (parsedTorrent) {
// Attempt to set infoHash property synchronously
self.infoHash = parsedTorrent.infoHash
+ self._debugId = parsedTorrent.infoHash.toString('hex').substring(0, 7)
process.nextTick(function () {
if (self.destroyed) return
self._onParsedTorrent(parsedTorrent)
@@ -277,6 +278,8 @@ Torrent.prototype._onParsedTorrent = function (parsedTorrent) {
}
Torrent.prototype._processParsedTorrent = function (parsedTorrent) {
+ this._debugId = parsedTorrent.infoHash.toString('hex').substring(0, 7)
+
if (this.announce) {
// Allow specifying trackers via `opts` parameter
parsedTorrent.announce = parsedTorrent.announce.concat(this.announce)
@@ -1634,7 +1637,7 @@ Torrent.prototype.resume = function () {
Torrent.prototype._debug = function () {
var args = [].slice.call(arguments)
- args[0] = '[' + this._debugId + '] ' + args[0]
+ args[0] = '[' + this.client._debugId + '] [' + this._debugId + '] ' + args[0]
debug.apply(null, args)
}