@rsdk/logging 4.0.1 → 4.0.2
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 +1 -1
- package/dist/logger.factory.js +27 -2
- package/dist/logger.factory.js.map +1 -1
- package/package.json +3 -3
- package/src/logger.factory.ts +36 -2
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.0.2](https://github.com/R-Vision/rsdk/compare/v4.0.2-next.0...v4.0.2) (2023-12-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @rsdk/logging
|
|
9
|
+
|
|
10
|
+
## [4.0.2-next.0](https://github.com/R-Vision/rsdk/compare/v4.0.1...v4.0.2-next.0) (2023-12-10)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **tracing:** pfm-601 update deps and add full disable auto instumentation ([f744a4d](https://github.com/R-Vision/rsdk/commit/f744a4de5a679b0fa6673e6fd881931dbd6d074f))
|
|
15
|
+
|
|
6
16
|
## [4.0.1](https://github.com/R-Vision/rsdk/compare/v4.0.1-next.2...v4.0.1) (2023-12-07)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @rsdk/logging
|
package/dist/logger.factory.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare class LoggerFactory {
|
|
|
36
36
|
* TRACING_ENABLED. Т. е. нас сначала нужно полностью инициализировать систему
|
|
37
37
|
* конфигурации, а уже потом решать - делать инструментирование или нет.
|
|
38
38
|
*/
|
|
39
|
-
static applyInstrumentations(): void;
|
|
39
|
+
static applyInstrumentations<T extends Record<string, any>>(logHookFunction?: (record: T) => void): void;
|
|
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
|
@@ -51,10 +51,35 @@ class LoggerFactory {
|
|
|
51
51
|
* TRACING_ENABLED. Т. е. нас сначала нужно полностью инициализировать систему
|
|
52
52
|
* конфигурации, а уже потом решать - делать инструментирование или нет.
|
|
53
53
|
*/
|
|
54
|
-
static applyInstrumentations() {
|
|
54
|
+
static applyInstrumentations(logHookFunction) {
|
|
55
55
|
const { stream, ...other } = this.opts;
|
|
56
56
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
57
|
-
this._globalPino = require('pino')(
|
|
57
|
+
this._globalPino = require('pino')({
|
|
58
|
+
...other,
|
|
59
|
+
/**
|
|
60
|
+
* Функция которая позволяет добавить дополнительные данные в логи Pino
|
|
61
|
+
*/
|
|
62
|
+
hooks: logHookFunction
|
|
63
|
+
? {
|
|
64
|
+
/**
|
|
65
|
+
* Реализация взята с официальной документации
|
|
66
|
+
* https://getpino.io/#/docs/api?id=logmethod
|
|
67
|
+
*/
|
|
68
|
+
logMethod: function (inputArgs,
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
70
|
+
method) {
|
|
71
|
+
if (inputArgs.length >= 2) {
|
|
72
|
+
const arg1 = inputArgs.shift() || {};
|
|
73
|
+
const arg2 = inputArgs.shift();
|
|
74
|
+
logHookFunction(arg1);
|
|
75
|
+
// eslint-disable-next-line unicorn/prefer-reflect-apply
|
|
76
|
+
return method.apply(this, [arg1, arg2, ...inputArgs]);
|
|
77
|
+
}
|
|
78
|
+
return method.apply(this, inputArgs);
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
: {},
|
|
82
|
+
}, stream);
|
|
58
83
|
}
|
|
59
84
|
static opts = {
|
|
60
85
|
level: defaults_1.DEFAULT_LEVEL,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.factory.js","sourceRoot":"","sources":["../src/logger.factory.ts"],"names":[],"mappings":";;;;;;AAA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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,cAAI,CAAC,WAAW,EAAE,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;QAElE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,wBAAa,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9E,CAAC;;AA3GH,sCA4GC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/logging",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Base framework independent logging functionality",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"rxjs": "^7.8.1"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@rsdk/common": "^4.0.
|
|
21
|
+
"@rsdk/common": "^4.0.2"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "520c37138fc8a5f15a7aa4a0e117bd20191e6a89"
|
|
24
24
|
}
|
package/src/logger.factory.ts
CHANGED
|
@@ -60,11 +60,45 @@ export class LoggerFactory {
|
|
|
60
60
|
* TRACING_ENABLED. Т. е. нас сначала нужно полностью инициализировать систему
|
|
61
61
|
* конфигурации, а уже потом решать - делать инструментирование или нет.
|
|
62
62
|
*/
|
|
63
|
-
static applyInstrumentations
|
|
63
|
+
static applyInstrumentations<T extends Record<string, any>>(
|
|
64
|
+
logHookFunction?: (record: T) => void,
|
|
65
|
+
): void {
|
|
64
66
|
const { stream, ...other } = this.opts;
|
|
65
67
|
|
|
66
68
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
67
|
-
this._globalPino = require('pino')(
|
|
69
|
+
this._globalPino = require('pino')(
|
|
70
|
+
{
|
|
71
|
+
...other,
|
|
72
|
+
/**
|
|
73
|
+
* Функция которая позволяет добавить дополнительные данные в логи Pino
|
|
74
|
+
*/
|
|
75
|
+
hooks: logHookFunction
|
|
76
|
+
? {
|
|
77
|
+
/**
|
|
78
|
+
* Реализация взята с официальной документации
|
|
79
|
+
* https://getpino.io/#/docs/api?id=logmethod
|
|
80
|
+
*/
|
|
81
|
+
logMethod: function (
|
|
82
|
+
inputArgs: any[],
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
84
|
+
method: Function,
|
|
85
|
+
): unknown {
|
|
86
|
+
if (inputArgs.length >= 2) {
|
|
87
|
+
const arg1: T = inputArgs.shift() || {};
|
|
88
|
+
const arg2 = inputArgs.shift();
|
|
89
|
+
|
|
90
|
+
logHookFunction(arg1);
|
|
91
|
+
|
|
92
|
+
// eslint-disable-next-line unicorn/prefer-reflect-apply
|
|
93
|
+
return method.apply(this, [arg1, arg2, ...inputArgs]);
|
|
94
|
+
}
|
|
95
|
+
return method.apply(this, inputArgs);
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
: {},
|
|
99
|
+
},
|
|
100
|
+
stream,
|
|
101
|
+
);
|
|
68
102
|
}
|
|
69
103
|
|
|
70
104
|
private static opts: LoggerOptions = {
|