dolphindb 2.0.943 → 2.0.944

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -498,6 +498,8 @@ export declare class DDB {
498
498
  python: boolean;
499
499
  /** 是否为流数据连接,非流数据这个字段恒为 null Whether it is a streaming data connection, this field is always null for non-streaming data */
500
500
  streaming: StreamingData;
501
+ /** 是否打印每个 rpc 的信息用于调试 */
502
+ verbose: boolean;
501
503
  print_message_buffer: boolean;
502
504
  print_object_buffer: boolean;
503
505
  print_message: boolean;
@@ -519,7 +521,8 @@ export declare class DDB {
519
521
  - password?: DolphinDB 登录密码,默认 `'123456'` DolphinDB password, default `'123456'`
520
522
  - python?: 设置 python session flag,默认 `false` set python session flag, default `false`
521
523
  - streaming?: 设置该选项后,该 WebSocket 连接只用于流数据 When this option is set, the WebSocket connection is only used for streaming data
522
-
524
+ - verbose?: 是否打印每个 rpc 的信息用于调试
525
+
523
526
  @example
524
527
  let ddb = new DDB('ws://127.0.0.1:8848')
525
528
 
@@ -537,6 +540,7 @@ export declare class DDB {
537
540
  password?: string;
538
541
  python?: boolean;
539
542
  streaming?: StreamingParams;
543
+ verbose?: boolean;
540
544
  });
541
545
  private on_message;
542
546
  private on_error;
package/index.js CHANGED
@@ -2138,6 +2138,8 @@ export class DdbConnectionError extends Error {
2138
2138
  ddb;
2139
2139
  constructor(ddb, error) {
2140
2140
  super(error?.message || `${ddb.url} ${t('连接出错了,可能由于网络原因连接已被关闭,或服务器断开连接')}`, { cause: error });
2141
+ if (error)
2142
+ this.cause = error;
2141
2143
  this.ddb = ddb;
2142
2144
  }
2143
2145
  }
@@ -2183,6 +2185,8 @@ export class DDB {
2183
2185
  python = false;
2184
2186
  /** 是否为流数据连接,非流数据这个字段恒为 null Whether it is a streaming data connection, this field is always null for non-streaming data */
2185
2187
  streaming = null;
2188
+ /** 是否打印每个 rpc 的信息用于调试 */
2189
+ verbose = false;
2186
2190
  // --- 内部选项, 状态
2187
2191
  print_message_buffer = false;
2188
2192
  print_object_buffer = false;
@@ -2207,7 +2211,8 @@ export class DDB {
2207
2211
  - password?: DolphinDB 登录密码,默认 `'123456'` DolphinDB password, default `'123456'`
2208
2212
  - python?: 设置 python session flag,默认 `false` set python session flag, default `false`
2209
2213
  - streaming?: 设置该选项后,该 WebSocket 连接只用于流数据 When this option is set, the WebSocket connection is only used for streaming data
2210
-
2214
+ - verbose?: 是否打印每个 rpc 的信息用于调试
2215
+
2211
2216
  @example
2212
2217
  let ddb = new DDB('ws://127.0.0.1:8848')
2213
2218
 
@@ -2221,6 +2226,8 @@ export class DDB {
2221
2226
  */
2222
2227
  constructor(url, options = {}) {
2223
2228
  this.url = url;
2229
+ if (options.verbose !== undefined)
2230
+ this.verbose = options.verbose;
2224
2231
  if (options.autologin !== undefined)
2225
2232
  this.autologin = options.autologin;
2226
2233
  if (options.username !== undefined)
@@ -2441,19 +2448,28 @@ export class DDB {
2441
2448
  const command = this.enc.encode((() => {
2442
2449
  switch (type) {
2443
2450
  case 'function':
2451
+ if (this.verbose)
2452
+ console.log(func + args.map(arg => inspect(arg, { colors: false })).join(', ').bracket());
2444
2453
  return 'function\n' +
2445
2454
  `${func}\n` +
2446
2455
  `${args.length}\n` +
2447
2456
  `${Number(DDB.le_client)}\n`;
2448
2457
  case 'script':
2458
+ if (this.verbose)
2459
+ console.log(script);
2449
2460
  return 'script\n' +
2450
2461
  script;
2451
2462
  case 'variable':
2463
+ if (this.verbose)
2464
+ for (let i = 0; i < vars.length; i++)
2465
+ console.log(`${vars[i]} = ${inspect(args[i], { colors: false })}`);
2452
2466
  return 'variable\n' +
2453
2467
  `${vars.join(',')}\n` +
2454
2468
  `${vars.length}\n` +
2455
2469
  `${Number(DDB.le_client)}\n`;
2456
2470
  case 'connect':
2471
+ if (this.verbose)
2472
+ console.log('connect()');
2457
2473
  return 'connect\n';
2458
2474
  }
2459
2475
  })());