@naturalcycles/redis-lib 4.6.0 → 4.7.0

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.
@@ -13,7 +13,7 @@ export interface CommonClient extends AsyncDisposable {
13
13
  export interface RedisClientCfg {
14
14
  redisOptions?: RedisOptions;
15
15
  /**
16
- * Defaults to console.
16
+ * Defaults to consoleLogger.
17
17
  */
18
18
  logger?: CommonLogger;
19
19
  }
@@ -1,4 +1,5 @@
1
1
  import { _assert } from '@naturalcycles/js-lib/error';
2
+ import { consoleLogger } from '@naturalcycles/js-lib/log';
2
3
  import { _stringMapEntries } from '@naturalcycles/js-lib/types';
3
4
  import { Pipeline } from '@naturalcycles/nodejs-lib/stream';
4
5
  /**
@@ -12,7 +13,7 @@ import { Pipeline } from '@naturalcycles/nodejs-lib/stream';
12
13
  export class RedisClient {
13
14
  constructor(cfg = {}) {
14
15
  this.cfg = {
15
- logger: console,
16
+ logger: consoleLogger,
16
17
  ...cfg,
17
18
  redisOptions: {
18
19
  showFriendlyErrorStack: true,
@@ -51,7 +52,7 @@ export class RedisClient {
51
52
  async disconnect() {
52
53
  const redis = await this.redis();
53
54
  this.log('redis: quit...');
54
- this.log(`redis: quit`, await redis.quit());
55
+ this.log({ msg: `redis: quit`, result: await redis.quit() });
55
56
  this.connected = false;
56
57
  }
57
58
  async [Symbol.asyncDispose]() {
@@ -293,7 +294,7 @@ export class RedisClient {
293
294
  await fn(pipeline);
294
295
  await pipeline.exec();
295
296
  }
296
- log(...args) {
297
- this.cfg.logger.log(...args);
297
+ log(input) {
298
+ this.cfg.logger.log(input);
298
299
  }
299
300
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "tslib": "^2"
10
10
  },
11
11
  "devDependencies": {
12
- "@naturalcycles/dev-lib": "0.0.0",
12
+ "@naturalcycles/dev-lib": "20.64.0",
13
13
  "@types/node": "^26",
14
14
  "typescript": "^7"
15
15
  },
@@ -38,7 +38,7 @@
38
38
  "engines": {
39
39
  "node": ">=24.10.0"
40
40
  },
41
- "version": "4.6.0",
41
+ "version": "4.7.0",
42
42
  "description": "Redis implementation of CommonKeyValueDB interface",
43
43
  "author": "Natural Cycles Team",
44
44
  "license": "MIT",
@@ -1,5 +1,6 @@
1
1
  import { _assert } from '@naturalcycles/js-lib/error'
2
- import type { CommonLogger } from '@naturalcycles/js-lib/log'
2
+ import { consoleLogger } from '@naturalcycles/js-lib/log'
3
+ import type { CommonLogger, LogInput } from '@naturalcycles/js-lib/log'
3
4
  import type {
4
5
  AnyObject,
5
6
  NullableBuffer,
@@ -25,7 +26,7 @@ export interface RedisClientCfg {
25
26
  redisOptions?: RedisOptions
26
27
 
27
28
  /**
28
- * Defaults to console.
29
+ * Defaults to consoleLogger.
29
30
  */
30
31
  logger?: CommonLogger
31
32
  }
@@ -41,7 +42,7 @@ export interface RedisClientCfg {
41
42
  export class RedisClient implements CommonClient {
42
43
  constructor(cfg: RedisClientCfg = {}) {
43
44
  this.cfg = {
44
- logger: console,
45
+ logger: consoleLogger,
45
46
  ...cfg,
46
47
  redisOptions: {
47
48
  showFriendlyErrorStack: true,
@@ -91,7 +92,7 @@ export class RedisClient implements CommonClient {
91
92
  async disconnect(): Promise<void> {
92
93
  const redis = await this.redis()
93
94
  this.log('redis: quit...')
94
- this.log(`redis: quit`, await redis.quit())
95
+ this.log({ msg: `redis: quit`, result: await redis.quit() })
95
96
  this.connected = false
96
97
  }
97
98
 
@@ -403,7 +404,7 @@ export class RedisClient implements CommonClient {
403
404
  await pipeline.exec()
404
405
  }
405
406
 
406
- private log(...args: any[]): void {
407
- this.cfg.logger.log(...args)
407
+ private log(input: LogInput): void {
408
+ this.cfg.logger.log(input)
408
409
  }
409
410
  }