From eb7477c9552e482304fe5d932fb5e40e785f81b2 Mon Sep 17 00:00:00 2001 From: Tiago Date: Thu, 16 Jan 2020 18:32:20 +0000 Subject: [PATCH] Support logger from npm require (#3) * Export DefaultLogger * Add Documentation --- README.md | 14 ++++++++++++++ index.js | 2 ++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 35ba11f..f59e514 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,20 @@ ws.on('error', function(err) { See websocket client [api docs](./doc/websocket-client.md) for further information. +### Customise Logging +Pass a custom logger which supports the log methods `silly`, `debug`, `notice`, `info`, `warning` and `error`, or override methods from the default logger as desired: + +```js +const { RestClient, WebsocketClient, DefaultLogger } = require('@pxtrn/bybit-api'); + +// Disable all logging on the silly level +DefaultLogger.silly = () => {}; + +const API_KEY = 'xxx'; +const PRIVATE_KEY = 'yyy'; + +const ws = new WebsocketClient({key: API_KEY, secret: PRIVATE_KEY}, DefaultLogger); +``` ## Donations diff --git a/index.js b/index.js index 27ac090..988e292 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,9 @@ const RestClient = require('./lib/rest-client.js'); const WebsocketClient = require('./lib/websocket-client.js'); +const DefaultLogger = require('./lib/logger.js'); module.exports = { RestClient, WebsocketClient, + DefaultLogger }