chore(): update default logger examples
This commit is contained in:
@@ -63,7 +63,6 @@ Node.js, JavaScript & TypeScript SDK for the Bybit REST APIs and WebSockets:
|
||||
- [WebSockets](#websockets)
|
||||
- [WebSocket Subscriptions - Consuming Events](#websocket-subscriptions---consuming-events)
|
||||
- [Websocket API - Sending Orders via WebSockets](#websocket-api---sending-orders-via-websockets)
|
||||
- [Specifying Other Markets](#specifying-other-markets)
|
||||
- [Consumer Load Balancing](#balancing-load-across-multiple-connections)
|
||||
|
||||
## Additional Features
|
||||
@@ -485,14 +484,6 @@ See the [examples/ws-api-promises.ts](./examples/ws-api-promises.ts) example for
|
||||
|
||||
---
|
||||
|
||||
### Specifying other markets
|
||||
|
||||
The WebsocketClient can be configured to a specific API group using the market parameter. These are the currently available API groups:
|
||||
| API Category | Market | Description |
|
||||
|:----------------------------: |:-------------------: |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| V5 Subscriptions | `market: 'v5'` | The [v5](https://bybit-exchange.github.io/docs/v5/ws/connect) websocket topics for all categories under one market. Use the subscribeV5 method when subscribing to v5 topics. |
|
||||
|
||||
|
||||
### Balancing load across multiple connections
|
||||
|
||||
The WebsocketClient will automatically prepare one connection per API group, for all topics in that API group. Any topics that you subscribe to on that WebSocket client will automatically be added to the same connection.
|
||||
|
||||
@@ -29,14 +29,14 @@ const restClient = new RestClientV5({
|
||||
// Optional, uncomment the "silly" override to log a lot more info about what the WS client is doing
|
||||
const customLogger = {
|
||||
...DefaultLogger,
|
||||
// silly: (...params) => console.log('trace', ...params),
|
||||
// trace: (...params) => console.log('trace', ...params),
|
||||
};
|
||||
|
||||
const wsClient = new WebsocketClient(
|
||||
{
|
||||
key: key,
|
||||
secret: secret,
|
||||
market: 'v5',
|
||||
|
||||
/**
|
||||
* Set this to true to enable demo trading for the private account data WS
|
||||
* Topics: order,execution,position,wallet,greeks
|
||||
|
||||
@@ -46,10 +46,10 @@ const restClient = new RestClientV5({
|
||||
},
|
||||
});
|
||||
|
||||
// Optional, uncomment the "silly" override to log a lot more info about what the WS client is doing
|
||||
// Optional, uncomment the "trace" override to log a lot more info about what the WS client is doing
|
||||
const customLogger = {
|
||||
...DefaultLogger,
|
||||
// silly: (...params) => console.log('trace', ...params),
|
||||
// trace: (...params) => console.log('trace', ...params),
|
||||
};
|
||||
|
||||
const wsClient = new WebsocketClient(
|
||||
|
||||
@@ -4,10 +4,10 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src';
|
||||
// or
|
||||
// import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from 'bybit-api';
|
||||
|
||||
// Create & inject a custom logger to disable the silly logging level (empty function)
|
||||
// Create & inject a custom logger to enable the trace logging level (empty function)
|
||||
const logger = {
|
||||
...DefaultLogger,
|
||||
silly: () => {},
|
||||
// trace: (...params) => console.log('trace', ...params),
|
||||
};
|
||||
|
||||
const key = process.env.API_KEY;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src';
|
||||
|
||||
const logger = {
|
||||
...DefaultLogger,
|
||||
silly: (...params) => console.log('silly', ...params),
|
||||
trace: (...params) => console.log('trace', ...params),
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -17,13 +17,7 @@ const logger = {
|
||||
* - Heartbeats/ping/pong/reconnects are all handled automatically.
|
||||
* If a connection drops, the client will clean it up, respawn a fresh connection and resubscribe for you.
|
||||
*/
|
||||
const wsClient = new WebsocketClient(
|
||||
{
|
||||
// Previously required, this parameter is now optional:
|
||||
// market: 'v5',
|
||||
},
|
||||
logger,
|
||||
);
|
||||
const wsClient = new WebsocketClient({}, logger);
|
||||
|
||||
wsClient.on('update', (data) => {
|
||||
console.log('raw message received ', JSON.stringify(data));
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { WebsocketClient } from '../../src';
|
||||
|
||||
describe.skip('Public V5 Websocket client', () => {
|
||||
const api = new WebsocketClient({
|
||||
market: 'v5',
|
||||
});
|
||||
const api = new WebsocketClient({});
|
||||
|
||||
const linearSymbol = 'BTCUSDT';
|
||||
const linearCategory = 'linear';
|
||||
|
||||
Reference in New Issue
Block a user