@rsdk/logging 5.2.1-next.1 → 5.3.0-next.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.
- package/CHANGELOG.md +10 -0
- package/dist/implementations/pino-logger.class.d.ts +9 -6
- package/dist/implementations/pino-logger.class.js +16 -19
- package/dist/implementations/pino-logger.class.js.map +1 -1
- package/dist/logger.interface.d.ts +11 -3
- package/package.json +3 -3
- package/src/implementations/pino-logger.class.ts +41 -34
- package/src/logger.interface.ts +11 -3
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
|
+
## [5.3.0-next.0](https://github.com/R-Vision/rsdk/compare/v5.2.1-next.2...v5.3.0-next.0) (2024-10-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @rsdk/logging
|
|
9
|
+
|
|
10
|
+
## [5.2.1-next.2](https://github.com/R-Vision/rsdk/compare/v5.2.1-next.1...v5.2.1-next.2) (2024-10-21)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* logging + otel ([#297](https://github.com/R-Vision/rsdk/issues/297)) ([3b06993](https://github.com/R-Vision/rsdk/commit/3b069936c6aaa0eb5285b82f079ffe435a38bbdc))
|
|
15
|
+
|
|
6
16
|
## [5.2.1-next.1](https://github.com/R-Vision/rsdk/compare/v5.2.1-next.0...v5.2.1-next.1) (2024-10-18)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @rsdk/logging
|
|
@@ -18,21 +18,24 @@ export declare class PinoLogger implements ILogger {
|
|
|
18
18
|
private readonly emit;
|
|
19
19
|
constructor(pino: GetLogger, emit: OnMessage, context: LoggingContext);
|
|
20
20
|
get pino(): Pino;
|
|
21
|
+
trace(params: Params): void;
|
|
21
22
|
trace(message: string, params?: Params): void;
|
|
23
|
+
debug(params: Params): void;
|
|
22
24
|
debug(message: string, params?: Params): void;
|
|
23
25
|
info(message: string, params?: Params): void;
|
|
26
|
+
warn(error: ErrorLike): void;
|
|
24
27
|
warn(message: string): void;
|
|
25
28
|
warn(message: string, params: Params | ErrorLike): void;
|
|
26
29
|
error(error: Error): void;
|
|
27
30
|
error(message: string): void;
|
|
28
|
-
error(message: string, error:
|
|
31
|
+
error(message: string, error: ErrorLike): void;
|
|
29
32
|
fatal(error: Error): void;
|
|
30
33
|
fatal(message: string): void;
|
|
31
|
-
fatal(message: string, error:
|
|
32
|
-
log(level: LogLevel, message: string): void;
|
|
33
|
-
log(level: LogLevel, error:
|
|
34
|
+
fatal(message: string, error: ErrorLike): void;
|
|
35
|
+
log(level: LogLevel, message: string | Params | ErrorLike): void;
|
|
36
|
+
log(level: LogLevel, error: ErrorLike): void;
|
|
34
37
|
log(level: LogLevel, params: Params): void;
|
|
35
|
-
log(level: LogLevel, message: string, params?: Params): void;
|
|
36
|
-
log(level: LogLevel, message: string, error?:
|
|
38
|
+
log(level: LogLevel, message: string | Params | ErrorLike, params?: Params): void;
|
|
39
|
+
log(level: LogLevel, message: string | Params | ErrorLike, error?: ErrorLike): void;
|
|
37
40
|
}
|
|
38
41
|
export {};
|
|
@@ -19,27 +19,23 @@ class PinoLogger {
|
|
|
19
19
|
get pino() {
|
|
20
20
|
return this._pino();
|
|
21
21
|
}
|
|
22
|
-
trace(
|
|
23
|
-
this.log(types_1.LogLevel.trace,
|
|
22
|
+
trace(arg0, params) {
|
|
23
|
+
this.log(types_1.LogLevel.trace, arg0, params);
|
|
24
24
|
}
|
|
25
|
-
debug(
|
|
26
|
-
this.log(types_1.LogLevel.debug,
|
|
25
|
+
debug(arg0, params) {
|
|
26
|
+
this.log(types_1.LogLevel.debug, arg0, params);
|
|
27
27
|
}
|
|
28
28
|
info(message, params) {
|
|
29
29
|
this.log(types_1.LogLevel.info, message, params);
|
|
30
30
|
}
|
|
31
|
-
warn(
|
|
32
|
-
this.log(types_1.LogLevel.warn,
|
|
31
|
+
warn(arg0, arg1) {
|
|
32
|
+
this.log(types_1.LogLevel.warn, arg0, arg1);
|
|
33
33
|
}
|
|
34
34
|
error(arg0, arg1) {
|
|
35
|
-
|
|
36
|
-
const err = (typeof arg0 === 'object' ? arg0 : arg1) ?? undefined;
|
|
37
|
-
this.log(types_1.LogLevel.error, message, err);
|
|
35
|
+
this.log(types_1.LogLevel.error, arg0, arg1);
|
|
38
36
|
}
|
|
39
37
|
fatal(arg0, arg1) {
|
|
40
|
-
|
|
41
|
-
const err = (typeof arg0 === 'object' ? arg0 : arg1) ?? undefined;
|
|
42
|
-
this.log(types_1.LogLevel.fatal, message, err);
|
|
38
|
+
this.log(types_1.LogLevel.fatal, arg0, arg1);
|
|
43
39
|
}
|
|
44
40
|
log(level, arg1, arg2) {
|
|
45
41
|
if (this.pino.levelVal > this.pino.levels.values[level]) {
|
|
@@ -48,9 +44,14 @@ class PinoLogger {
|
|
|
48
44
|
const args = {
|
|
49
45
|
context: this.context,
|
|
50
46
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
let message = undefined;
|
|
48
|
+
if (typeof arg1 === 'string') {
|
|
49
|
+
message = arg1;
|
|
50
|
+
}
|
|
51
|
+
else if ((0, common_1.isErrorLike)(arg1)) {
|
|
52
|
+
message = arg1.message;
|
|
53
|
+
}
|
|
54
|
+
const paramsOrError = typeof arg1 === 'string' ? arg2 : arg1;
|
|
54
55
|
if (paramsOrError) {
|
|
55
56
|
const options = {
|
|
56
57
|
sortKeys: common_1.sortErrorKeys,
|
|
@@ -62,10 +63,6 @@ class PinoLogger {
|
|
|
62
63
|
Object.assign(args, (0, common_1.normalizer)()(paramsOrError, options));
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
/**
|
|
66
|
-
* TODO: Может быть, как-то извернуться и дать _pino индексную
|
|
67
|
-
* сигнатуру.
|
|
68
|
-
*/
|
|
69
66
|
this.emit(level, { ...args, message });
|
|
70
67
|
this.pino[level](args, message);
|
|
71
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pino-logger.class.js","sourceRoot":"","sources":["../../src/implementations/pino-logger.class.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"pino-logger.class.js","sourceRoot":"","sources":["../../src/implementations/pino-logger.class.ts"],"names":[],"mappings":";;;AACA,yCAAsE;AAGtE,wCAA8C;AAG9C,oCAAoC;AAUpC,MAAa,UAAU;IACJ,OAAO,CAAS;IAEjC;;OAEG;IACc,KAAK,CAAY;IACjB,IAAI,CAAY;IAEjC,YAAY,IAAe,EAAE,IAAe,EAAE,OAAuB;QACnE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,IAAA,0BAAgB,EAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAID,KAAK,CAAC,IAAqB,EAAE,MAAe;QAC1C,IAAI,CAAC,GAAG,CAAC,gBAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAID,KAAK,CAAC,IAAqB,EAAE,MAAe;QAC1C,IAAI,CAAC,GAAG,CAAC,gBAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,MAAe;QACnC,IAAI,CAAC,GAAG,CAAC,gBAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAKD,IAAI,CAAC,IAAwB,EAAE,IAAyB;QACtD,IAAI,CAAC,GAAG,CAAC,gBAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAKD,KAAK,CAAC,IAAo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AAC,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;CACF;AA3GD,gCA2GC"}
|
|
@@ -3,20 +3,28 @@ import type { LogLevel, Params } from './types';
|
|
|
3
3
|
export interface ILogger {
|
|
4
4
|
fatal(error: Error): void;
|
|
5
5
|
fatal(message: string): void;
|
|
6
|
-
fatal(message: string,
|
|
6
|
+
fatal(message: string, params: Params): void;
|
|
7
|
+
fatal(message: string, error: ErrorLike): void;
|
|
7
8
|
error(error: Error): void;
|
|
8
9
|
error(message: string): void;
|
|
9
|
-
error(message: string,
|
|
10
|
+
error(message: string, params: Params): void;
|
|
11
|
+
error(message: string, error: ErrorLike): void;
|
|
12
|
+
warn(error: ErrorLike): void;
|
|
10
13
|
warn(message: string): void;
|
|
11
14
|
warn(message: string, params: Params): void;
|
|
15
|
+
warn(message: string, error: ErrorLike): void;
|
|
12
16
|
info(message: string): void;
|
|
13
17
|
info(message: string, params: Params): void;
|
|
18
|
+
debug(error: ErrorLike): void;
|
|
19
|
+
debug(params: Params): void;
|
|
14
20
|
debug(message: string): void;
|
|
15
21
|
debug(message: string, params: Params): void;
|
|
22
|
+
trace(error: ErrorLike): void;
|
|
23
|
+
trace(params: Params): void;
|
|
16
24
|
trace(message: string): void;
|
|
17
25
|
trace(message: string, params: Params): void;
|
|
18
26
|
log(level: LogLevel, message: string): void;
|
|
19
|
-
log(level: LogLevel, error:
|
|
27
|
+
log(level: LogLevel, error: ErrorLike): void;
|
|
20
28
|
log(level: LogLevel, params: Params): void;
|
|
21
29
|
log(level: LogLevel, message: string, params?: Params): void;
|
|
22
30
|
log(level: LogLevel, message: string, error?: ErrorLike): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/logging",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0-next.0",
|
|
4
4
|
"description": "Base framework independent logging functionality",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
},
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"pino": "^8.
|
|
14
|
+
"pino": "^8.21.0",
|
|
15
15
|
"rxjs": "^7.8.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@rsdk/common": "*"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "15f91b8250e2726de273f0a93df4eae3908d1b55"
|
|
21
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ErrorLike, NormalizeOptions } from '@rsdk/common';
|
|
2
|
-
import { normalizer, sortErrorKeys } from '@rsdk/common';
|
|
2
|
+
import { isErrorLike, normalizer, sortErrorKeys } from '@rsdk/common';
|
|
3
3
|
import type { Logger as Pino } from 'pino';
|
|
4
4
|
|
|
5
5
|
import { stringifyContext } from '../helpers';
|
|
@@ -34,53 +34,60 @@ export class PinoLogger implements ILogger {
|
|
|
34
34
|
return this._pino();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
trace(
|
|
38
|
-
|
|
37
|
+
trace(params: Params): void;
|
|
38
|
+
trace(message: string, params?: Params): void;
|
|
39
|
+
trace(arg0: string | Params, params?: Params): void {
|
|
40
|
+
this.log(LogLevel.trace, arg0, params);
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
debug(
|
|
42
|
-
|
|
43
|
+
debug(params: Params): void;
|
|
44
|
+
debug(message: string, params?: Params): void;
|
|
45
|
+
debug(arg0: string | Params, params?: Params): void {
|
|
46
|
+
this.log(LogLevel.debug, arg0, params);
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
info(message: string, params?: Params): void {
|
|
46
50
|
this.log(LogLevel.info, message, params);
|
|
47
51
|
}
|
|
48
52
|
|
|
53
|
+
warn(error: ErrorLike): void;
|
|
49
54
|
warn(message: string): void;
|
|
50
55
|
warn(message: string, params: Params | ErrorLike): void;
|
|
51
|
-
warn(
|
|
52
|
-
this.log(LogLevel.warn,
|
|
56
|
+
warn(arg0: string | ErrorLike, arg1?: Params | ErrorLike): void {
|
|
57
|
+
this.log(LogLevel.warn, arg0, arg1);
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
error(error: Error): void;
|
|
56
61
|
error(message: string): void;
|
|
57
|
-
error(message: string, error:
|
|
58
|
-
error(arg0: string | Error, arg1?:
|
|
59
|
-
|
|
60
|
-
const err = (typeof arg0 === 'object' ? arg0 : arg1) ?? undefined;
|
|
61
|
-
|
|
62
|
-
this.log(LogLevel.error, message, err);
|
|
62
|
+
error(message: string, error: ErrorLike): void;
|
|
63
|
+
error(arg0: string | Error, arg1?: ErrorLike): void {
|
|
64
|
+
this.log(LogLevel.error, arg0, arg1);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
fatal(error: Error): void;
|
|
66
68
|
fatal(message: string): void;
|
|
67
|
-
fatal(message: string, error:
|
|
68
|
-
fatal(arg0: string | Error, arg1?:
|
|
69
|
-
|
|
70
|
-
const err = (typeof arg0 === 'object' ? arg0 : arg1) ?? undefined;
|
|
71
|
-
|
|
72
|
-
this.log(LogLevel.fatal, message, err);
|
|
69
|
+
fatal(message: string, error: ErrorLike): void;
|
|
70
|
+
fatal(arg0: string | Error, arg1?: ErrorLike): void {
|
|
71
|
+
this.log(LogLevel.fatal, arg0, arg1);
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
log(level: LogLevel, message: string): void;
|
|
76
|
-
log(level: LogLevel, error:
|
|
74
|
+
log(level: LogLevel, message: string | Params | ErrorLike): void;
|
|
75
|
+
log(level: LogLevel, error: ErrorLike): void;
|
|
77
76
|
log(level: LogLevel, params: Params): void;
|
|
78
|
-
log(level: LogLevel, message: string, params?: Params): void;
|
|
79
|
-
log(level: LogLevel, message: string, error?: Error): void;
|
|
80
77
|
log(
|
|
81
78
|
level: LogLevel,
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
message: string | Params | ErrorLike,
|
|
80
|
+
params?: Params,
|
|
81
|
+
): void;
|
|
82
|
+
log(
|
|
83
|
+
level: LogLevel,
|
|
84
|
+
message: string | Params | ErrorLike,
|
|
85
|
+
error?: ErrorLike,
|
|
86
|
+
): void;
|
|
87
|
+
log(
|
|
88
|
+
level: LogLevel,
|
|
89
|
+
arg1: string | Params | ErrorLike,
|
|
90
|
+
arg2?: Params | ErrorLike,
|
|
84
91
|
): void {
|
|
85
92
|
if (this.pino.levelVal > this.pino.levels.values[level]) {
|
|
86
93
|
return;
|
|
@@ -90,10 +97,15 @@ export class PinoLogger implements ILogger {
|
|
|
90
97
|
context: this.context,
|
|
91
98
|
};
|
|
92
99
|
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
let message: string | undefined = undefined;
|
|
101
|
+
|
|
102
|
+
if (typeof arg1 === 'string') {
|
|
103
|
+
message = arg1;
|
|
104
|
+
} else if (isErrorLike(arg1)) {
|
|
105
|
+
message = arg1.message;
|
|
106
|
+
}
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
const paramsOrError = typeof arg1 === 'string' ? arg2 : arg1;
|
|
97
109
|
|
|
98
110
|
if (paramsOrError) {
|
|
99
111
|
const options: NormalizeOptions = {
|
|
@@ -107,12 +119,7 @@ export class PinoLogger implements ILogger {
|
|
|
107
119
|
}
|
|
108
120
|
}
|
|
109
121
|
|
|
110
|
-
/**
|
|
111
|
-
* TODO: Может быть, как-то извернуться и дать _pino индексную
|
|
112
|
-
* сигнатуру.
|
|
113
|
-
*/
|
|
114
122
|
this.emit(level, { ...args, message });
|
|
115
|
-
|
|
116
|
-
(this.pino as any)[level](args, message);
|
|
123
|
+
this.pino[level](args, message);
|
|
117
124
|
}
|
|
118
125
|
}
|
package/src/logger.interface.ts
CHANGED
|
@@ -5,26 +5,34 @@ import type { LogLevel, Params } from './types';
|
|
|
5
5
|
export interface ILogger {
|
|
6
6
|
fatal(error: Error): void;
|
|
7
7
|
fatal(message: string): void;
|
|
8
|
-
fatal(message: string,
|
|
8
|
+
fatal(message: string, params: Params): void;
|
|
9
|
+
fatal(message: string, error: ErrorLike): void;
|
|
9
10
|
|
|
10
11
|
error(error: Error): void;
|
|
11
12
|
error(message: string): void;
|
|
12
|
-
error(message: string,
|
|
13
|
+
error(message: string, params: Params): void;
|
|
14
|
+
error(message: string, error: ErrorLike): void;
|
|
13
15
|
|
|
16
|
+
warn(error: ErrorLike): void;
|
|
14
17
|
warn(message: string): void;
|
|
15
18
|
warn(message: string, params: Params): void;
|
|
19
|
+
warn(message: string, error: ErrorLike): void;
|
|
16
20
|
|
|
17
21
|
info(message: string): void;
|
|
18
22
|
info(message: string, params: Params): void;
|
|
19
23
|
|
|
24
|
+
debug(error: ErrorLike): void;
|
|
25
|
+
debug(params: Params): void;
|
|
20
26
|
debug(message: string): void;
|
|
21
27
|
debug(message: string, params: Params): void;
|
|
22
28
|
|
|
29
|
+
trace(error: ErrorLike): void;
|
|
30
|
+
trace(params: Params): void;
|
|
23
31
|
trace(message: string): void;
|
|
24
32
|
trace(message: string, params: Params): void;
|
|
25
33
|
|
|
26
34
|
log(level: LogLevel, message: string): void;
|
|
27
|
-
log(level: LogLevel, error:
|
|
35
|
+
log(level: LogLevel, error: ErrorLike): void;
|
|
28
36
|
log(level: LogLevel, params: Params): void;
|
|
29
37
|
log(level: LogLevel, message: string, params?: Params): void;
|
|
30
38
|
log(level: LogLevel, message: string, error?: ErrorLike): void;
|