@rsdk/logging 4.2.5-next.0 → 4.3.0-next.1
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/CHANGELOG.md +10 -0
- package/dist/logger.factory.d.ts +11 -11
- package/dist/logger.factory.js +26 -19
- package/dist/logger.factory.js.map +1 -1
- package/package.json +3 -3
- package/src/logger.factory.ts +30 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.3.0-next.1](https://github.com/R-Vision/rsdk/compare/v4.3.0-next.0...v4.3.0-next.1) (2024-03-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @rsdk/logging
|
|
9
|
+
|
|
10
|
+
## [4.3.0-next.0](https://github.com/R-Vision/rsdk/compare/v4.2.5-next.0...v4.3.0-next.0) (2024-03-19)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* reworked cli system ([745ebf5](https://github.com/R-Vision/rsdk/commit/745ebf53635de135a4a9083f47ce833efe2d4411))
|
|
15
|
+
|
|
6
16
|
## [4.2.5-next.0](https://github.com/R-Vision/rsdk/compare/v4.2.4...v4.2.5-next.0) (2024-03-04)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @rsdk/logging
|
package/dist/logger.factory.d.ts
CHANGED
|
@@ -13,17 +13,6 @@ export declare class LoggerFactory {
|
|
|
13
13
|
* @param opts Опции логгер
|
|
14
14
|
*/
|
|
15
15
|
static reconfigure(opts: Partial<LoggerOptions>): void;
|
|
16
|
-
/**
|
|
17
|
-
* Under the hood every logger instance will use this
|
|
18
|
-
* static instance. Motivation for this is that it's much
|
|
19
|
-
* easier to substitute the instance when configuration is
|
|
20
|
-
* changed.
|
|
21
|
-
*
|
|
22
|
-
* Downside is that the idea is not composable with child
|
|
23
|
-
* loggers (which are no used anywhere yet)
|
|
24
|
-
*/
|
|
25
|
-
private static _globalPino;
|
|
26
|
-
private static events;
|
|
27
16
|
/**
|
|
28
17
|
* Этот метод должен быть вызван после того, как подключен instrumentation-pino.
|
|
29
18
|
* Пакет instrumentation-pino модифицирует require. Согласно предполагаемому автором
|
|
@@ -37,6 +26,17 @@ export declare class LoggerFactory {
|
|
|
37
26
|
* конфигурации, а уже потом решать - делать инструментирование или нет.
|
|
38
27
|
*/
|
|
39
28
|
static applyInstrumentations<T extends Record<string, any>>(logHookFunction?: (record: T) => void): void;
|
|
29
|
+
private static events;
|
|
30
|
+
/**
|
|
31
|
+
* Under the hood every logger instance will use this
|
|
32
|
+
* static instance. Motivation for this is that it's much
|
|
33
|
+
* easier to substitute the instance when configuration is
|
|
34
|
+
* changed.
|
|
35
|
+
*
|
|
36
|
+
* Downside is that the idea is not composable with child
|
|
37
|
+
* loggers (which are no used anywhere yet)
|
|
38
|
+
*/
|
|
39
|
+
private static _globalPino;
|
|
40
40
|
private static opts;
|
|
41
41
|
static onMessage(handler: OnMessage): void;
|
|
42
42
|
static create(context: LoggingContext): ILogger;
|
package/dist/logger.factory.js
CHANGED
|
@@ -5,9 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.LoggerFactory = void 0;
|
|
7
7
|
const node_events_1 = __importDefault(require("node:events"));
|
|
8
|
-
const pino_1 = __importDefault(require("pino"));
|
|
9
8
|
const defaults_1 = require("./defaults");
|
|
10
9
|
const implementations_1 = require("./implementations");
|
|
10
|
+
/**
|
|
11
|
+
* ATTENTION: require('pino') тут не просто так, в общем они нужны для корректной работы хуков из `@opentelemetry/instrumentation-pino`
|
|
12
|
+
*/
|
|
13
|
+
const requirePino = () => {
|
|
14
|
+
return require('pino');
|
|
15
|
+
};
|
|
11
16
|
/**
|
|
12
17
|
* TODO: Дополнить доку
|
|
13
18
|
* Фабрика является статической потому что
|
|
@@ -23,22 +28,9 @@ class LoggerFactory {
|
|
|
23
28
|
static reconfigure(opts) {
|
|
24
29
|
this.applyOptions(opts);
|
|
25
30
|
const { stream, ...other } = this.opts;
|
|
26
|
-
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
32
|
+
this._globalPino = requirePino()(other, stream);
|
|
27
33
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Under the hood every logger instance will use this
|
|
30
|
-
* static instance. Motivation for this is that it's much
|
|
31
|
-
* easier to substitute the instance when configuration is
|
|
32
|
-
* changed.
|
|
33
|
-
*
|
|
34
|
-
* Downside is that the idea is not composable with child
|
|
35
|
-
* loggers (which are no used anywhere yet)
|
|
36
|
-
*/
|
|
37
|
-
static _globalPino = (0, pino_1.default)({
|
|
38
|
-
level: defaults_1.DEFAULT_LEVEL,
|
|
39
|
-
});
|
|
40
|
-
// eslint-disable-next-line unicorn/prefer-event-target
|
|
41
|
-
static events = new node_events_1.default();
|
|
42
34
|
/**
|
|
43
35
|
* Этот метод должен быть вызван после того, как подключен instrumentation-pino.
|
|
44
36
|
* Пакет instrumentation-pino модифицирует require. Согласно предполагаемому автором
|
|
@@ -54,7 +46,7 @@ class LoggerFactory {
|
|
|
54
46
|
static applyInstrumentations(logHookFunction) {
|
|
55
47
|
const { stream, ...other } = this.opts;
|
|
56
48
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
57
|
-
this._globalPino =
|
|
49
|
+
this._globalPino = requirePino()({
|
|
58
50
|
...other,
|
|
59
51
|
/**
|
|
60
52
|
* Функция которая позволяет добавить дополнительные данные в логи Pino
|
|
@@ -81,10 +73,25 @@ class LoggerFactory {
|
|
|
81
73
|
: {},
|
|
82
74
|
}, stream);
|
|
83
75
|
}
|
|
76
|
+
// eslint-disable-next-line unicorn/prefer-event-target
|
|
77
|
+
static events = new node_events_1.default();
|
|
78
|
+
/**
|
|
79
|
+
* Under the hood every logger instance will use this
|
|
80
|
+
* static instance. Motivation for this is that it's much
|
|
81
|
+
* easier to substitute the instance when configuration is
|
|
82
|
+
* changed.
|
|
83
|
+
*
|
|
84
|
+
* Downside is that the idea is not composable with child
|
|
85
|
+
* loggers (which are no used anywhere yet)
|
|
86
|
+
*/
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
88
|
+
static _globalPino = requirePino()({
|
|
89
|
+
level: defaults_1.DEFAULT_LEVEL,
|
|
90
|
+
});
|
|
84
91
|
static opts = {
|
|
85
92
|
level: defaults_1.DEFAULT_LEVEL,
|
|
86
93
|
redact: [],
|
|
87
|
-
stream:
|
|
94
|
+
stream: requirePino().destination(),
|
|
88
95
|
};
|
|
89
96
|
static onMessage(handler) {
|
|
90
97
|
this.events.on('msg', handler);
|
|
@@ -93,7 +100,7 @@ class LoggerFactory {
|
|
|
93
100
|
return new implementations_1.PinoLogger(() => this._globalPino, (level, data) => this.events.emit('msg', level, data), context);
|
|
94
101
|
}
|
|
95
102
|
static applyOptions(opts) {
|
|
96
|
-
const { redact, level, stream =
|
|
103
|
+
const { redact, level, stream = requirePino().destination() } = opts || {};
|
|
97
104
|
Object.assign(this.opts, { redact, level: level ?? defaults_1.DEFAULT_LEVEL, stream });
|
|
98
105
|
}
|
|
99
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.factory.js","sourceRoot":"","sources":["../src/logger.factory.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAuC;
|
|
1
|
+
{"version":3,"file":"logger.factory.js","sourceRoot":"","sources":["../src/logger.factory.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAuC;AAIvC,yCAA2C;AAC3C,uDAA+C;AAS/C;;GAEG;AACH,MAAM,WAAW,GAAG,GAAiB,EAAE;IACrC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAa,aAAa;IACxB;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,IAA4B;Q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W,EAAE,CAAC;QAC/C,KAAK,EAAE,wBAAa;KACrB,CAAC,CAAC;IAEK,MAAM,CAAC,IAAI,GAAkB;QACnC,KAAK,EAAE,wBAAa;QACpB,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,WAAW,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;IAEF,MAAM,CAAC,SAAS,CAAC,OAAkB;QACjC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,OAAuB;QACnC,OAAO,IAAI,4BAAU,CACnB,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EACtB,CAAC,KAAe,EAAE,IAAa,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EACxE,OAAO,CACR,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,IAA4B;QACtD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC,WAAW,EAAE,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;QAE3E,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,wBAAa,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9E,CAAC;;AA7GH,sCA8GC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/logging",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0-next.1",
|
|
4
4
|
"description": "Base framework independent logging functionality",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"rxjs": "^7.8.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@rsdk/common": "^4.
|
|
18
|
+
"@rsdk/common": "^4.3.0-next.1"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "da58041323f3145aa436e02774d36d44606c1217"
|
|
21
21
|
}
|
package/src/logger.factory.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'node:events';
|
|
2
|
+
import type _pino from 'pino';
|
|
2
3
|
import type { Logger as Pino } from 'pino';
|
|
3
|
-
import pino from 'pino';
|
|
4
4
|
|
|
5
5
|
import { DEFAULT_LEVEL } from './defaults';
|
|
6
6
|
import { PinoLogger } from './implementations';
|
|
@@ -12,6 +12,13 @@ import type {
|
|
|
12
12
|
OnMessage,
|
|
13
13
|
} from './types';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* ATTENTION: require('pino') тут не просто так, в общем они нужны для корректной работы хуков из `@opentelemetry/instrumentation-pino`
|
|
17
|
+
*/
|
|
18
|
+
const requirePino = (): typeof _pino => {
|
|
19
|
+
return require('pino');
|
|
20
|
+
};
|
|
21
|
+
|
|
15
22
|
/**
|
|
16
23
|
* TODO: Дополнить доку
|
|
17
24
|
* Фабрика является статической потому что
|
|
@@ -29,25 +36,10 @@ export class LoggerFactory {
|
|
|
29
36
|
|
|
30
37
|
const { stream, ...other } = this.opts;
|
|
31
38
|
|
|
32
|
-
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
40
|
+
this._globalPino = requirePino()(other, stream);
|
|
33
41
|
}
|
|
34
42
|
|
|
35
|
-
/**
|
|
36
|
-
* Under the hood every logger instance will use this
|
|
37
|
-
* static instance. Motivation for this is that it's much
|
|
38
|
-
* easier to substitute the instance when configuration is
|
|
39
|
-
* changed.
|
|
40
|
-
*
|
|
41
|
-
* Downside is that the idea is not composable with child
|
|
42
|
-
* loggers (which are no used anywhere yet)
|
|
43
|
-
*/
|
|
44
|
-
private static _globalPino: Pino = pino({
|
|
45
|
-
level: DEFAULT_LEVEL,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// eslint-disable-next-line unicorn/prefer-event-target
|
|
49
|
-
private static events = new EventEmitter();
|
|
50
|
-
|
|
51
43
|
/**
|
|
52
44
|
* Этот метод должен быть вызван после того, как подключен instrumentation-pino.
|
|
53
45
|
* Пакет instrumentation-pino модифицирует require. Согласно предполагаемому автором
|
|
@@ -66,7 +58,7 @@ export class LoggerFactory {
|
|
|
66
58
|
const { stream, ...other } = this.opts;
|
|
67
59
|
|
|
68
60
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
69
|
-
this._globalPino =
|
|
61
|
+
this._globalPino = requirePino()(
|
|
70
62
|
{
|
|
71
63
|
...other,
|
|
72
64
|
/**
|
|
@@ -101,10 +93,27 @@ export class LoggerFactory {
|
|
|
101
93
|
);
|
|
102
94
|
}
|
|
103
95
|
|
|
96
|
+
// eslint-disable-next-line unicorn/prefer-event-target
|
|
97
|
+
private static events = new EventEmitter();
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Under the hood every logger instance will use this
|
|
101
|
+
* static instance. Motivation for this is that it's much
|
|
102
|
+
* easier to substitute the instance when configuration is
|
|
103
|
+
* changed.
|
|
104
|
+
*
|
|
105
|
+
* Downside is that the idea is not composable with child
|
|
106
|
+
* loggers (which are no used anywhere yet)
|
|
107
|
+
*/
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
109
|
+
private static _globalPino: Pino = requirePino()({
|
|
110
|
+
level: DEFAULT_LEVEL,
|
|
111
|
+
});
|
|
112
|
+
|
|
104
113
|
private static opts: LoggerOptions = {
|
|
105
114
|
level: DEFAULT_LEVEL,
|
|
106
115
|
redact: [],
|
|
107
|
-
stream:
|
|
116
|
+
stream: requirePino().destination(),
|
|
108
117
|
};
|
|
109
118
|
|
|
110
119
|
static onMessage(handler: OnMessage): void {
|
|
@@ -120,7 +129,7 @@ export class LoggerFactory {
|
|
|
120
129
|
}
|
|
121
130
|
|
|
122
131
|
private static applyOptions(opts: Partial<LoggerOptions>): void {
|
|
123
|
-
const { redact, level, stream =
|
|
132
|
+
const { redact, level, stream = requirePino().destination() } = opts || {};
|
|
124
133
|
|
|
125
134
|
Object.assign(this.opts, { redact, level: level ?? DEFAULT_LEVEL, stream });
|
|
126
135
|
}
|