xshell 1.0.182 → 1.0.183

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.182",
3
+ "version": "1.0.183",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
package/server.d.ts CHANGED
@@ -48,6 +48,8 @@ export declare class Server {
48
48
  /** 设置后会启用 websocket rpc */
49
49
  remote?: Remote;
50
50
  colors: boolean;
51
+ /** 输出日志时包含日期 */
52
+ log_date: boolean;
51
53
  /** 启用后增加 stdio 订阅相关的 remote.funcs */
52
54
  stdio_subscribable?: boolean;
53
55
  stdio_subscribers: (((chunk: Uint8Array | string) => Promise<void>) & {
@@ -57,7 +59,7 @@ export declare class Server {
57
59
  /** 原始 process.stdout.write 函数 bind 后的备份 */
58
60
  stdout_write: Function;
59
61
  stderr_write: Function;
60
- constructor({ name, http, http2, http_port, http2_port, fpd_certs, default_hostnames, remote, funcs, stdio_subscribable, }: {
62
+ constructor({ name, http, http2, http_port, http2_port, fpd_certs, default_hostnames, remote, funcs, stdio_subscribable, log_date }: {
61
63
  name: string;
62
64
  http?: boolean;
63
65
  http2?: boolean;
@@ -68,6 +70,7 @@ export declare class Server {
68
70
  remote?: Remote;
69
71
  funcs?: Remote['funcs'];
70
72
  stdio_subscribable?: boolean;
73
+ log_date?: boolean;
71
74
  });
72
75
  /** start http server and listen */
73
76
  start(): Promise<void>;
package/server.js CHANGED
@@ -43,13 +43,15 @@ export class Server {
43
43
  /** 设置后会启用 websocket rpc */
44
44
  remote;
45
45
  colors = util.inspect.defaultOptions.colors;
46
+ /** 输出日志时包含日期 */
47
+ log_date = false;
46
48
  /** 启用后增加 stdio 订阅相关的 remote.funcs */
47
49
  stdio_subscribable;
48
50
  stdio_subscribers = [];
49
51
  /** 原始 process.stdout.write 函数 bind 后的备份 */
50
52
  stdout_write;
51
53
  stderr_write;
52
- constructor({ name, http, http2, http_port, http2_port, fpd_certs, default_hostnames, remote, funcs, stdio_subscribable, }) {
54
+ constructor({ name, http, http2, http_port, http2_port, fpd_certs, default_hostnames, remote, funcs, stdio_subscribable, log_date }) {
53
55
  this.name = name;
54
56
  if (http)
55
57
  this.http = http;
@@ -64,6 +66,8 @@ export class Server {
64
66
  this.fpd_certs = fpd_certs;
65
67
  if (default_hostnames)
66
68
  this.default_hostnames = default_hostnames;
69
+ if (log_date !== undefined)
70
+ this.log_date = log_date;
67
71
  if (remote)
68
72
  this.remote = remote;
69
73
  else if (funcs)
@@ -257,7 +261,7 @@ export class Server {
257
261
  const ip = request.socket.remoteAddress.replace(/^::ffff:/, '');
258
262
  console.log(
259
263
  // 时间
260
- `${new Date().to_time_str()} ` +
264
+ `${this.log_date ? new Date().to_str() : new Date().to_time_str()} ` +
261
265
  // ip(位置)
262
266
  (ip || '').limit(40) + ' ' +
263
267
  // ua
@@ -359,7 +363,7 @@ export class Server {
359
363
  let { method } = request;
360
364
  let s = '';
361
365
  // 时间
362
- s += `${new Date().to_time_str()} `;
366
+ s += `${this.log_date ? new Date().to_str() : new Date().to_time_str()} `;
363
367
  // ip(位置)
364
368
  s += (ip || '').limit(40) + ' ';
365
369
  // ua