Add silly logging
This commit is contained in:
@@ -24,10 +24,11 @@ to the server once connection has been lost.
|
|||||||
Custom logger must contain the following methods:
|
Custom logger must contain the following methods:
|
||||||
```js
|
```js
|
||||||
const logger = {
|
const logger = {
|
||||||
debug: function(message, data) {}
|
silly: function(message, data) {},
|
||||||
notice: function(message, data) {}
|
debug: function(message, data) {},
|
||||||
info: function(message, data) {}
|
notice: function(message, data) {},
|
||||||
warning: function(message, data) {}
|
info: function(message, data) {},
|
||||||
|
warning: function(message, data) {},
|
||||||
error: function(message, data) {},
|
error: function(message, data) {},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
silly: function() {console.log(arguments)},
|
||||||
debug: function() {console.log(arguments)},
|
debug: function() {console.log(arguments)},
|
||||||
notice: function() {console.log(arguments)},
|
notice: function() {console.log(arguments)},
|
||||||
info: function() {console.info(arguments)},
|
info: function() {console.info(arguments)},
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ module.exports = class WebsocketClient extends EventEmitter {
|
|||||||
clearTimeout(this.pongTimeout);
|
clearTimeout(this.pongTimeout);
|
||||||
this.pongTimeout = null;
|
this.pongTimeout = null;
|
||||||
|
|
||||||
this.logger.debug('Sending ping', {category: 'bybit-ws'});
|
this.logger.silly('Sending ping', {category: 'bybit-ws'});
|
||||||
this.ws.send(JSON.stringify({op: 'ping'}));
|
this.ws.send(JSON.stringify({op: 'ping'}));
|
||||||
|
|
||||||
this.pongTimeout = setTimeout(() => {
|
this.pongTimeout = setTimeout(() => {
|
||||||
@@ -186,7 +186,7 @@ module.exports = class WebsocketClient extends EventEmitter {
|
|||||||
_handleResponse(response) {
|
_handleResponse(response) {
|
||||||
if(response.request && response.request.op === 'ping' && response.ret_msg === 'pong') {
|
if(response.request && response.request.op === 'ping' && response.ret_msg === 'pong') {
|
||||||
if(response.success === true) {
|
if(response.success === true) {
|
||||||
this.logger.debug('pong recieved', {category: 'bybit-ws'});
|
this.logger.silly('pong recieved', {category: 'bybit-ws'});
|
||||||
clearTimeout(this.pongTimeout);
|
clearTimeout(this.pongTimeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user