Support logger from npm require (#3)
* Export DefaultLogger * Add Documentation
This commit is contained in:
14
README.md
14
README.md
@@ -74,6 +74,20 @@ ws.on('error', function(err) {
|
|||||||
|
|
||||||
See websocket client [api docs](./doc/websocket-client.md) for further information.
|
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
|
## Donations
|
||||||
|
|
||||||
|
|||||||
2
index.js
2
index.js
@@ -1,7 +1,9 @@
|
|||||||
const RestClient = require('./lib/rest-client.js');
|
const RestClient = require('./lib/rest-client.js');
|
||||||
const WebsocketClient = require('./lib/websocket-client.js');
|
const WebsocketClient = require('./lib/websocket-client.js');
|
||||||
|
const DefaultLogger = require('./lib/logger.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
RestClient,
|
RestClient,
|
||||||
WebsocketClient,
|
WebsocketClient,
|
||||||
|
DefaultLogger
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user