use "debug" for logging instead of console
This commit is contained in:
parent
cc018effaf
commit
138d2b8bf0
7
index.js
7
index.js
@ -2,6 +2,9 @@
|
||||
|
||||
const Client = require('./lib/client');
|
||||
|
||||
const debug = require("debug");
|
||||
const debugLog = debug("electrumClient");
|
||||
|
||||
class ElectrumClient extends Client {
|
||||
constructor(port, host, protocol, options) {
|
||||
super(port, host, protocol, options);
|
||||
@ -63,7 +66,7 @@ class ElectrumClient extends Client {
|
||||
this.timeout = setTimeout(() => {
|
||||
if (this.timeLastCall !== 0 && new Date().getTime() > this.timeLastCall + 5000) {
|
||||
this.server_ping().catch((reason) => {
|
||||
console.log('keepalive ping failed because of', reason);
|
||||
debugLog('keepalive ping failed because of', reason);
|
||||
});
|
||||
}
|
||||
}, 5000);
|
||||
@ -78,7 +81,7 @@ class ElectrumClient extends Client {
|
||||
}
|
||||
|
||||
reconnect() {
|
||||
console.log('electrum reconnect');
|
||||
debugLog("Electrum reconnect");
|
||||
this.initSocket();
|
||||
return this.initElectrum(this.electrumConfig);
|
||||
}
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
const debug = require("debug");
|
||||
const debugLog = debug("electrumClient");
|
||||
|
||||
/**
|
||||
* Simple wrapper to mimick Socket class from NET package, since TLS package has slightly different API.
|
||||
* We implement several methods that TCP sockets are expected to have. We will proxy call them as soon as
|
||||
@ -69,7 +72,7 @@ class TlsSocketWrapper {
|
||||
connect(port, host, callback) {
|
||||
// resulting TLSSocket extends <net.Socket>
|
||||
this._socket = this._tls.connect({ port: port, host: host, rejectUnauthorized: false }, () => {
|
||||
console.log('TLS Connected to ', host, port);
|
||||
debugLog('TLS Connected to ', host, port);
|
||||
return callback();
|
||||
});
|
||||
|
||||
|
||||
@ -17,6 +17,9 @@ const TlsSocketWrapper = require('./TlsSocketWrapper.js');
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const util = require('./util');
|
||||
|
||||
const debug = require("debug");
|
||||
const debugLog = debug("electrumClient");
|
||||
|
||||
class Client {
|
||||
constructor(port, host, protocol, options) {
|
||||
this.id = 0;
|
||||
@ -156,7 +159,7 @@ class Client {
|
||||
callback(null, msg.result || msg);
|
||||
}
|
||||
} else {
|
||||
console.log("Can't get callback");
|
||||
debugLog("Can't get callback");
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +191,7 @@ class Client {
|
||||
}
|
||||
|
||||
onError(e) {
|
||||
console.log('OnError:' + e);
|
||||
debugLog('OnError:' + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,9 @@
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"debug": "~4.1.1",
|
||||
},
|
||||
"devDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user