Support logger from npm require (#3)

* Export DefaultLogger
* Add Documentation
This commit is contained in:
Tiago
2020-01-16 18:32:20 +00:00
committed by Stefan Aebischer
parent 4aaa3e0a95
commit eb7477c955
2 changed files with 16 additions and 0 deletions

View File

@@ -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

View File

@@ -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
}