@rsdk/logging 5.0.0-next.2 → 5.0.0-next.4
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 +14 -0
- package/dist/logger.factory.d.ts +15 -12
- package/dist/logger.factory.js +23 -21
- package/dist/logger.factory.js.map +1 -1
- package/package.json +2 -2
- package/src/logger.factory.ts +26 -24
- package/src/logger.interface.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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
|
+
## [5.0.0-next.4](https://github.com/R-Vision/rsdk/compare/v5.0.0-next.3...v5.0.0-next.4) (2024-07-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @rsdk/logging
|
|
9
|
+
|
|
10
|
+
## [5.0.0-next.3](https://github.com/R-Vision/rsdk/compare/v5.0.0-next.2...v5.0.0-next.3) (2024-07-11)
|
|
11
|
+
|
|
12
|
+
### ⚠ BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* generalize tracing headers (#247)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* generalize tracing headers ([#247](https://github.com/R-Vision/rsdk/issues/247)) ([cee2ea6](https://github.com/R-Vision/rsdk/commit/cee2ea65c964705faf133397e285c051672c7512)), closes [#2](https://github.com/R-Vision/rsdk/issues/2) [#3](https://github.com/R-Vision/rsdk/issues/3) [#4](https://github.com/R-Vision/rsdk/issues/4) [#5](https://github.com/R-Vision/rsdk/issues/5)
|
|
19
|
+
|
|
6
20
|
## [5.0.0-next.2](https://github.com/R-Vision/rsdk/compare/v5.0.0-next.1...v5.0.0-next.2) (2024-07-10)
|
|
7
21
|
|
|
8
22
|
**Note:** Version bump only for package @rsdk/logging
|
package/dist/logger.factory.d.ts
CHANGED
|
@@ -5,6 +5,18 @@ import type { LoggerOptions, LoggingContext, OnMessage } from './types';
|
|
|
5
5
|
* Фабрика является статической потому что
|
|
6
6
|
*/
|
|
7
7
|
export declare class LoggerFactory {
|
|
8
|
+
private static events;
|
|
9
|
+
/**
|
|
10
|
+
* Under the hood every logger instance will use this
|
|
11
|
+
* static instance. Motivation for this is that it's much
|
|
12
|
+
* easier to substitute the instance when configuration is
|
|
13
|
+
* changed.
|
|
14
|
+
*
|
|
15
|
+
* Downside is that the idea is not composable with child
|
|
16
|
+
* loggers (which are no used anywhere yet)
|
|
17
|
+
*/
|
|
18
|
+
private static _globalPino;
|
|
19
|
+
private static opts;
|
|
8
20
|
/**
|
|
9
21
|
* Переконфигурация pino нужна потому, что изначально логгер инициализируется
|
|
10
22
|
* с дефолтными настройками, т. к. конфигурация ещё не прочитана.
|
|
@@ -24,20 +36,11 @@ export declare class LoggerFactory {
|
|
|
24
36
|
* что мы хотим, чтобы подключение инструментирование зависело от настройки
|
|
25
37
|
* TRACING_ENABLED. Т. е. нас сначала нужно полностью инициализировать систему
|
|
26
38
|
* конфигурации, а уже потом решать - делать инструментирование или нет.
|
|
27
|
-
*/
|
|
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
39
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
40
|
+
* UPD: Поскольку мы не используем теперь TRACING_ENABLED и включаем трейсинг
|
|
41
|
+
* при помощи cli - можно немного упростить архитектуру
|
|
38
42
|
*/
|
|
39
|
-
|
|
40
|
-
private static opts;
|
|
43
|
+
static applyInstrumentations<T extends Record<string, any>>(logHookFunction?: (record: T) => void): void;
|
|
41
44
|
static onMessage(handler: OnMessage): void;
|
|
42
45
|
static create(context: LoggingContext): ILogger;
|
|
43
46
|
private static applyOptions;
|
package/dist/logger.factory.js
CHANGED
|
@@ -18,6 +18,26 @@ const requirePino = () => {
|
|
|
18
18
|
* Фабрика является статической потому что
|
|
19
19
|
*/
|
|
20
20
|
class LoggerFactory {
|
|
21
|
+
// eslint-disable-next-line unicorn/prefer-event-target
|
|
22
|
+
static events = new node_events_1.default();
|
|
23
|
+
/**
|
|
24
|
+
* Under the hood every logger instance will use this
|
|
25
|
+
* static instance. Motivation for this is that it's much
|
|
26
|
+
* easier to substitute the instance when configuration is
|
|
27
|
+
* changed.
|
|
28
|
+
*
|
|
29
|
+
* Downside is that the idea is not composable with child
|
|
30
|
+
* loggers (which are no used anywhere yet)
|
|
31
|
+
*/
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
33
|
+
static _globalPino = requirePino()({
|
|
34
|
+
level: defaults_1.DEFAULT_LEVEL,
|
|
35
|
+
});
|
|
36
|
+
static opts = {
|
|
37
|
+
level: defaults_1.DEFAULT_LEVEL,
|
|
38
|
+
redact: [],
|
|
39
|
+
stream: requirePino().destination(),
|
|
40
|
+
};
|
|
21
41
|
/**
|
|
22
42
|
* Переконфигурация pino нужна потому, что изначально логгер инициализируется
|
|
23
43
|
* с дефолтными настройками, т. к. конфигурация ещё не прочитана.
|
|
@@ -28,7 +48,6 @@ class LoggerFactory {
|
|
|
28
48
|
static reconfigure(opts) {
|
|
29
49
|
this.applyOptions(opts);
|
|
30
50
|
const { stream, ...other } = this.opts;
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
32
51
|
this._globalPino = requirePino()(other, stream);
|
|
33
52
|
}
|
|
34
53
|
/**
|
|
@@ -42,6 +61,9 @@ class LoggerFactory {
|
|
|
42
61
|
* что мы хотим, чтобы подключение инструментирование зависело от настройки
|
|
43
62
|
* TRACING_ENABLED. Т. е. нас сначала нужно полностью инициализировать систему
|
|
44
63
|
* конфигурации, а уже потом решать - делать инструментирование или нет.
|
|
64
|
+
*
|
|
65
|
+
* UPD: Поскольку мы не используем теперь TRACING_ENABLED и включаем трейсинг
|
|
66
|
+
* при помощи cli - можно немного упростить архитектуру
|
|
45
67
|
*/
|
|
46
68
|
static applyInstrumentations(logHookFunction) {
|
|
47
69
|
const { stream, ...other } = this.opts;
|
|
@@ -73,26 +95,6 @@ class LoggerFactory {
|
|
|
73
95
|
: {},
|
|
74
96
|
}, stream);
|
|
75
97
|
}
|
|
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
|
-
});
|
|
91
|
-
static opts = {
|
|
92
|
-
level: defaults_1.DEFAULT_LEVEL,
|
|
93
|
-
redact: [],
|
|
94
|
-
stream: requirePino().destination(),
|
|
95
|
-
};
|
|
96
98
|
static onMessage(handler) {
|
|
97
99
|
this.events.on('msg', handler);
|
|
98
100
|
}
|
|
@@ -1 +1 @@
|
|
|
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;QAC7C,IAAI,CAAC,YAAY,CAAC,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AK,EAAE,KAAK,IAAI,wBAAa,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9E,CAAC;;AA/GH,sCAgHC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/logging",
|
|
3
|
-
"version": "5.0.0-next.
|
|
3
|
+
"version": "5.0.0-next.4",
|
|
4
4
|
"description": "Base framework independent logging functionality",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@rsdk/common": "*"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "8f0a0ae9d8d01ef98ce95cb4aa1c28638f376b69"
|
|
21
21
|
}
|
package/src/logger.factory.ts
CHANGED
|
@@ -24,6 +24,29 @@ const requirePino = (): typeof _pino => {
|
|
|
24
24
|
* Фабрика является статической потому что
|
|
25
25
|
*/
|
|
26
26
|
export class LoggerFactory {
|
|
27
|
+
// eslint-disable-next-line unicorn/prefer-event-target
|
|
28
|
+
private static events = new EventEmitter();
|
|
29
|
+
|
|
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
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
40
|
+
private static _globalPino: Pino = requirePino()({
|
|
41
|
+
level: DEFAULT_LEVEL,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
private static opts: LoggerOptions = {
|
|
45
|
+
level: DEFAULT_LEVEL,
|
|
46
|
+
redact: [],
|
|
47
|
+
stream: requirePino().destination(),
|
|
48
|
+
};
|
|
49
|
+
|
|
27
50
|
/**
|
|
28
51
|
* Переконфигурация pino нужна потому, что изначально логгер инициализируется
|
|
29
52
|
* с дефолтными настройками, т. к. конфигурация ещё не прочитана.
|
|
@@ -36,7 +59,6 @@ export class LoggerFactory {
|
|
|
36
59
|
|
|
37
60
|
const { stream, ...other } = this.opts;
|
|
38
61
|
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
40
62
|
this._globalPino = requirePino()(other, stream);
|
|
41
63
|
}
|
|
42
64
|
|
|
@@ -51,6 +73,9 @@ export class LoggerFactory {
|
|
|
51
73
|
* что мы хотим, чтобы подключение инструментирование зависело от настройки
|
|
52
74
|
* TRACING_ENABLED. Т. е. нас сначала нужно полностью инициализировать систему
|
|
53
75
|
* конфигурации, а уже потом решать - делать инструментирование или нет.
|
|
76
|
+
*
|
|
77
|
+
* UPD: Поскольку мы не используем теперь TRACING_ENABLED и включаем трейсинг
|
|
78
|
+
* при помощи cli - можно немного упростить архитектуру
|
|
54
79
|
*/
|
|
55
80
|
static applyInstrumentations<T extends Record<string, any>>(
|
|
56
81
|
logHookFunction?: (record: T) => void,
|
|
@@ -93,29 +118,6 @@ export class LoggerFactory {
|
|
|
93
118
|
);
|
|
94
119
|
}
|
|
95
120
|
|
|
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
|
-
|
|
113
|
-
private static opts: LoggerOptions = {
|
|
114
|
-
level: DEFAULT_LEVEL,
|
|
115
|
-
redact: [],
|
|
116
|
-
stream: requirePino().destination(),
|
|
117
|
-
};
|
|
118
|
-
|
|
119
121
|
static onMessage(handler: OnMessage): void {
|
|
120
122
|
this.events.on('msg', handler);
|
|
121
123
|
}
|
package/src/logger.interface.ts
CHANGED
|
@@ -4,40 +4,28 @@ import type { LogLevel, Params } from './types';
|
|
|
4
4
|
|
|
5
5
|
export interface ILogger {
|
|
6
6
|
fatal(error: Error): void;
|
|
7
|
-
|
|
8
7
|
fatal(message: string): void;
|
|
9
|
-
|
|
10
8
|
fatal(message: string, error: Error | Params): void;
|
|
11
9
|
|
|
12
10
|
error(error: Error): void;
|
|
13
|
-
|
|
14
11
|
error(message: string): void;
|
|
15
|
-
|
|
16
12
|
error(message: string, error: Error | Params): void;
|
|
17
13
|
|
|
18
14
|
warn(message: string): void;
|
|
19
|
-
|
|
20
15
|
warn(message: string, params: Params): void;
|
|
21
16
|
|
|
22
17
|
info(message: string): void;
|
|
23
|
-
|
|
24
18
|
info(message: string, params: Params): void;
|
|
25
19
|
|
|
26
20
|
debug(message: string): void;
|
|
27
|
-
|
|
28
21
|
debug(message: string, params: Params): void;
|
|
29
22
|
|
|
30
23
|
trace(message: string): void;
|
|
31
|
-
|
|
32
24
|
trace(message: string, params: Params): void;
|
|
33
25
|
|
|
34
26
|
log(level: LogLevel, message: string): void;
|
|
35
|
-
|
|
36
27
|
log(level: LogLevel, error: Error): void;
|
|
37
|
-
|
|
38
28
|
log(level: LogLevel, params: Params): void;
|
|
39
|
-
|
|
40
29
|
log(level: LogLevel, message: string, params?: Params): void;
|
|
41
|
-
|
|
42
30
|
log(level: LogLevel, message: string, error?: ErrorLike): void;
|
|
43
31
|
}
|