pixtron / bybit-api

An unofficial node.js lowlevel wrapper for the Bybit Cryptocurrency Derivative exchange API
MIT License
21 stars 16 forks source link

Mute websocket ping/pong messages #2

Closed tiagosiebler closed 4 years ago

tiagosiebler commented 4 years ago

Can the websocket pongs be muted via a setting?

[Arguments] { '0': 'Sending ping', '1': { category: 'bybit-ws' } }
[Arguments] { '0': 'pong recieved', '1': { category: 'bybit-ws' } }
pixtron commented 4 years ago

You can pass a custom logger and not log the "silly" log level at all (see example below). You might as well use winston or any logger which supports the log methods silly, debug, notice, info, warning and error.

const {WebsocketClient} = require('@pxtrn/bybit-api');

const logger = {
  silly: function(message, data) {},
  debug: function(message, data) {console.log(message, data)},
  notice: function(message, data) {console.log(message, data)},
  info: function(message, data) {console.info(message, data)},
  warning: function(message, data) {console.warn(message, data)},
  error: function(message, data) {console.error(message, data)},
}

const options = {
  key: 'xxx',
  secret: 'yyy'
};

const ws = new WebsocketClient(options, logger);