@rsdk/core 5.12.0-next.9 → 5.13.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 +4 -0
- package/dist/config/parsers/index.d.ts +1 -0
- package/dist/config/parsers/index.js +1 -0
- package/dist/config/parsers/index.js.map +1 -1
- package/dist/config/parsers/string-record/exception.d.ts +4 -0
- package/dist/config/parsers/string-record/exception.js +14 -0
- package/dist/config/parsers/string-record/exception.js.map +1 -0
- package/dist/config/parsers/string-record/index.d.ts +2 -0
- package/dist/config/parsers/string-record/index.js +21 -0
- package/dist/config/parsers/string-record/index.js.map +1 -0
- package/dist/config/parsers/string-record/string-record.parser.d.ts +8 -0
- package/dist/config/parsers/string-record/string-record.parser.js +42 -0
- package/dist/config/parsers/string-record/string-record.parser.js.map +1 -0
- package/dist/logging/logger-initializing.module.d.ts +17 -1
- package/dist/logging/logger-initializing.module.js +90 -11
- package/dist/logging/logger-initializing.module.js.map +1 -1
- package/dist/logging/logging.config.d.ts +22 -0
- package/dist/logging/logging.config.js +124 -3
- package/dist/logging/logging.config.js.map +1 -1
- package/package.json +6 -2
- package/src/config/parsers/index.ts +1 -0
- package/src/config/parsers/string-record/exception.ts +10 -0
- package/src/config/parsers/string-record/index.ts +2 -0
- package/src/config/parsers/string-record/string-record.parser.ts +55 -0
- package/src/config/parsers/string-record/string-record.spec.ts +33 -0
- package/src/logging/logger-factory.lifecycle.spec.ts +91 -0
- package/src/logging/logger-initializing.module.spec.ts +245 -0
- package/src/logging/logger-initializing.module.ts +112 -16
- package/src/logging/logging.config.ts +106 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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.12.0](https://github.com/R-Vision/rsdk/compare/v5.12.0-next.9...v5.12.0) (2026-05-05)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @rsdk/core
|
|
9
|
+
|
|
6
10
|
## [5.11.0](https://github.com/R-Vision/rsdk/compare/v5.11.0-next.10...v5.11.0) (2025-12-22)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @rsdk/core
|
|
@@ -21,6 +21,7 @@ __exportStar(require("./number"), exports);
|
|
|
21
21
|
__exportStar(require("./path"), exports);
|
|
22
22
|
__exportStar(require("./size"), exports);
|
|
23
23
|
__exportStar(require("./string"), exports);
|
|
24
|
+
__exportStar(require("./string-record"), exports);
|
|
24
25
|
__exportStar(require("./timespan"), exports);
|
|
25
26
|
__exportStar(require("./url"), exports);
|
|
26
27
|
__exportStar(require("./array/"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/parsers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,yCAAuB;AACvB,wCAAsB;AACtB,2CAAyB;AACzB,yCAAuB;AACvB,yCAAuB;AACvB,2CAAyB;AACzB,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/parsers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,yCAAuB;AACvB,wCAAsB;AACtB,2CAAyB;AACzB,yCAAuB;AACvB,yCAAuB;AACvB,2CAAyB;AACzB,kDAAgC;AAChC,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidStringRecord = void 0;
|
|
4
|
+
const exceptions_1 = require("../../../exceptions");
|
|
5
|
+
class InvalidStringRecord extends exceptions_1.BootstrapException {
|
|
6
|
+
constructor(reason, value, cause) {
|
|
7
|
+
super(`Invalid string record: ${reason}`, {
|
|
8
|
+
cause,
|
|
9
|
+
details: { value },
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.InvalidStringRecord = InvalidStringRecord;
|
|
14
|
+
//# sourceMappingURL=exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exception.js","sourceRoot":"","sources":["../../../../src/config/parsers/string-record/exception.ts"],"names":[],"mappings":";;;AAAA,oDAAyD;AAEzD,MAAa,mBAAoB,SAAQ,+BAAkB;IACzD,YAAY,MAAc,EAAE,KAAc,EAAE,KAAe;QACzD,KAAK,CAAC,0BAA0B,MAAM,EAAE,EAAE;YACxC,KAAK;YACL,OAAO,EAAE,EAAE,KAAK,EAAE;SACnB,CAAC,CAAC;IACL,CAAC;CACF;AAPD,kDAOC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.InvalidStringRecord = void 0;
|
|
18
|
+
__exportStar(require("./string-record.parser"), exports);
|
|
19
|
+
var exception_1 = require("./exception");
|
|
20
|
+
Object.defineProperty(exports, "InvalidStringRecord", { enumerable: true, get: function () { return exception_1.InvalidStringRecord; } });
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/config/parsers/string-record/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,yCAAkD;AAAzC,gHAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PropertyParser } from '../../types';
|
|
2
|
+
/** Парсит JSON в плоский объект, проверяя, что все значения — строки. */
|
|
3
|
+
export declare class StringRecordParser implements PropertyParser<Record<string, string>> {
|
|
4
|
+
type(): string;
|
|
5
|
+
description(): string;
|
|
6
|
+
parse(value: unknown): Record<string, string>;
|
|
7
|
+
private toJson;
|
|
8
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringRecordParser = void 0;
|
|
4
|
+
const exception_1 = require("./exception");
|
|
5
|
+
/** Парсит JSON в плоский объект, проверяя, что все значения — строки. */
|
|
6
|
+
class StringRecordParser {
|
|
7
|
+
type() {
|
|
8
|
+
return 'json(Record<string, string>)';
|
|
9
|
+
}
|
|
10
|
+
description() {
|
|
11
|
+
return 'Parses a JSON object whose values are all strings';
|
|
12
|
+
}
|
|
13
|
+
parse(value) {
|
|
14
|
+
const parsed = this.toJson(value);
|
|
15
|
+
if (parsed === null ||
|
|
16
|
+
typeof parsed !== 'object' ||
|
|
17
|
+
Array.isArray(parsed)) {
|
|
18
|
+
throw new exception_1.InvalidStringRecord('expected a JSON object', value);
|
|
19
|
+
}
|
|
20
|
+
const result = {};
|
|
21
|
+
for (const [key, item] of Object.entries(parsed)) {
|
|
22
|
+
if (typeof item !== 'string') {
|
|
23
|
+
throw new exception_1.InvalidStringRecord(`value of key <${key}> must be a string, got ${typeof item}`, value);
|
|
24
|
+
}
|
|
25
|
+
result[key] = item;
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
toJson(value) {
|
|
30
|
+
if (typeof value !== 'string') {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(value);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
throw new exception_1.InvalidStringRecord('value is not valid JSON', value, error);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.StringRecordParser = StringRecordParser;
|
|
42
|
+
//# sourceMappingURL=string-record.parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-record.parser.js","sourceRoot":"","sources":["../../../../src/config/parsers/string-record/string-record.parser.ts"],"names":[],"mappings":";;;AAEA,2CAAkD;AAElD,yEAAyE;AACzE,MAAa,kBAAkB;IAG7B,IAAI;QACF,OAAO,8BAA8B,CAAC;IACxC,CAAC;IAED,WAAW;QACT,OAAO,mDAAmD,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,KAAc;QAClB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAElC,IACE,MAAM,KAAK,IAAI;YACf,OAAO,MAAM,KAAK,QAAQ;YAC1B,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EACrB,CAAC;YACD,MAAM,IAAI,+BAAmB,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,MAAM,GAA2B,EAAE,CAAC;QAE1C,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACjD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,MAAM,IAAI,+BAAmB,CAC3B,iBAAiB,GAAG,2BAA2B,OAAO,IAAI,EAAE,EAC5D,KAAK,CACN,CAAC;YACJ,CAAC;YAED,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QACrB,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,MAAM,CAAC,KAAc;QAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,+BAAmB,CAAC,yBAAyB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;CACF;AAjDD,gDAiDC"}
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
+
import type { OnApplicationShutdown } from '@nestjs/common';
|
|
1
2
|
import { LoggingConfig } from './logging.config';
|
|
2
|
-
export declare class LoggerInitializingModule {
|
|
3
|
+
export declare class LoggerInitializingModule implements OnApplicationShutdown {
|
|
4
|
+
private readonly config;
|
|
3
5
|
private static logger;
|
|
4
6
|
constructor(config: LoggingConfig);
|
|
7
|
+
onApplicationShutdown(): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Worker-транспорт нужен только для сетевых приёмников (OTEL/HTTP) либо по
|
|
10
|
+
* явному запросу. Для логирования лишь в stdout остаёмся на in-process
|
|
11
|
+
* stream — без воркеров, как было до multitransport.
|
|
12
|
+
*/
|
|
13
|
+
private buildDelivery;
|
|
5
14
|
private buildTransportOptions;
|
|
15
|
+
/**
|
|
16
|
+
* `otlp-logger` (через который работает pino-opentelemetry-transport) НЕ
|
|
17
|
+
* читает ключи `endpoint`/`serviceName`: endpoint задаётся через
|
|
18
|
+
* exporterOptions.url, а имя сервиса — через resourceAttributes/loggerName.
|
|
19
|
+
*/
|
|
20
|
+
private buildOtelTarget;
|
|
21
|
+
private buildHttpTarget;
|
|
6
22
|
}
|
|
@@ -20,41 +20,120 @@ const pino_1 = __importDefault(require("pino"));
|
|
|
20
20
|
const logging_config_1 = require("./logging.config");
|
|
21
21
|
let LoggerInitializingModule = class LoggerInitializingModule {
|
|
22
22
|
static { LoggerInitializingModule_1 = this; }
|
|
23
|
+
config;
|
|
23
24
|
static logger = logging_1.LoggerFactory.create(LoggerInitializingModule_1);
|
|
24
25
|
constructor(config) {
|
|
26
|
+
this.config = config;
|
|
25
27
|
const cfg = () => {
|
|
26
28
|
LoggerInitializingModule_1.logger.info(`Setting log level: <${config.level}>`, {
|
|
27
29
|
logLevel: config.level,
|
|
28
30
|
});
|
|
29
31
|
logging_1.LoggerFactory.reconfigure({
|
|
30
32
|
...config,
|
|
31
|
-
|
|
33
|
+
timestampFormat: config.logTimestampFormat,
|
|
34
|
+
...this.buildDelivery(config),
|
|
32
35
|
});
|
|
33
36
|
};
|
|
34
37
|
config.onUpdate(cfg);
|
|
35
38
|
cfg();
|
|
36
39
|
}
|
|
40
|
+
async onApplicationShutdown() {
|
|
41
|
+
await logging_1.LoggerFactory.shutdown(this.config.shutdownTimeout.millis());
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Worker-транспорт нужен только для сетевых приёмников (OTEL/HTTP) либо по
|
|
45
|
+
* явному запросу. Для логирования лишь в stdout остаёмся на in-process
|
|
46
|
+
* stream — без воркеров, как было до multitransport.
|
|
47
|
+
*/
|
|
48
|
+
buildDelivery(config) {
|
|
49
|
+
const needsTransport = config.otelEnabled ||
|
|
50
|
+
Boolean(config.httpEndpoint) ||
|
|
51
|
+
config.forceTransport;
|
|
52
|
+
return needsTransport
|
|
53
|
+
? { transport: this.buildTransportOptions(config) }
|
|
54
|
+
: {
|
|
55
|
+
stream: pino_1.default.destination({
|
|
56
|
+
dest: process.stdout.fd,
|
|
57
|
+
sync: config.sync,
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
37
61
|
buildTransportOptions(config) {
|
|
38
62
|
const targets = [
|
|
39
63
|
{
|
|
40
64
|
target: 'pino/file',
|
|
41
|
-
options: {
|
|
65
|
+
options: {
|
|
66
|
+
destination: process.stdout.fd,
|
|
67
|
+
},
|
|
42
68
|
level: config.level,
|
|
43
69
|
},
|
|
44
70
|
];
|
|
71
|
+
// OTEL включается флагом (endpoint опционален — резолвится из стандартных
|
|
72
|
+
// OTEL_* env), а HTTP — наличием endpoint (у него стандартного discovery
|
|
73
|
+
// нет). Отсюда разные модели enable у двух сетевых транспортов.
|
|
45
74
|
if (config.otelEnabled) {
|
|
46
|
-
targets.push(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* (unsafe destructuring in pino-opentelemetry-transport)
|
|
51
|
-
*/
|
|
52
|
-
options: {},
|
|
53
|
-
level: config.level,
|
|
54
|
-
});
|
|
75
|
+
targets.push(this.buildOtelTarget(config));
|
|
76
|
+
}
|
|
77
|
+
if (config.httpEndpoint) {
|
|
78
|
+
targets.push(this.buildHttpTarget(config.httpEndpoint, config));
|
|
55
79
|
}
|
|
56
80
|
return { targets };
|
|
57
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* `otlp-logger` (через который работает pino-opentelemetry-transport) НЕ
|
|
84
|
+
* читает ключи `endpoint`/`serviceName`: endpoint задаётся через
|
|
85
|
+
* exporterOptions.url, а имя сервиса — через resourceAttributes/loggerName.
|
|
86
|
+
*/
|
|
87
|
+
buildOtelTarget(config) {
|
|
88
|
+
const exporterOptions = {};
|
|
89
|
+
// Без явного протокола otlp-logger резолвит его из стандартного
|
|
90
|
+
// OTEL_EXPORTER_OTLP_PROTOCOL env (default protobuf).
|
|
91
|
+
if (config.otelProtocol) {
|
|
92
|
+
exporterOptions.protocol = config.otelProtocol;
|
|
93
|
+
}
|
|
94
|
+
if (config.otelEndpoint) {
|
|
95
|
+
const exporterUrl = { url: config.otelEndpoint.href };
|
|
96
|
+
// url кладём под все три ключа: otlp-logger прочитает только
|
|
97
|
+
// соответствующий выбранному протоколу, остальные проигнорирует.
|
|
98
|
+
exporterOptions.httpExporterOptions = exporterUrl;
|
|
99
|
+
exporterOptions.protobufExporterOptions = exporterUrl;
|
|
100
|
+
exporterOptions.grpcExporterOptions = exporterUrl;
|
|
101
|
+
}
|
|
102
|
+
const options = {
|
|
103
|
+
logRecordProcessorOptions: {
|
|
104
|
+
recordProcessorType: 'batch',
|
|
105
|
+
exporterOptions,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
if (config.otelServiceName) {
|
|
109
|
+
options.loggerName = config.otelServiceName;
|
|
110
|
+
options.resourceAttributes = {
|
|
111
|
+
'service.name': config.otelServiceName,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
target: 'pino-opentelemetry-transport',
|
|
116
|
+
options,
|
|
117
|
+
level: config.level,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
buildHttpTarget(url, config) {
|
|
121
|
+
return {
|
|
122
|
+
target: 'pino-http-transport',
|
|
123
|
+
options: {
|
|
124
|
+
url: url.href,
|
|
125
|
+
headers: config.httpHeaders,
|
|
126
|
+
timeout: config.httpTimeout.millis(),
|
|
127
|
+
batchSize: config.httpBatchSize,
|
|
128
|
+
batchInterval: config.httpBatchInterval.millis(),
|
|
129
|
+
maxRetries: config.httpMaxRetries,
|
|
130
|
+
retryDelay: config.httpRetryDelay.millis(),
|
|
131
|
+
maxBufferSize: config.httpMaxBufferSize,
|
|
132
|
+
silent: config.httpSilent,
|
|
133
|
+
},
|
|
134
|
+
level: config.level,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
58
137
|
};
|
|
59
138
|
exports.LoggerInitializingModule = LoggerInitializingModule;
|
|
60
139
|
exports.LoggerInitializingModule = LoggerInitializingModule = LoggerInitializingModule_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger-initializing.module.js","sourceRoot":"","sources":["../../src/logging/logger-initializing.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"logger-initializing.module.js","sourceRoot":"","sources":["../../src/logging/logger-initializing.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,2CAAwC;AAExC,2CAA8C;AAC9C,gDAGc;AAEd,qDAAiD;AAG1C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;;IAGN;IAFrB,MAAM,CAAC,MAAM,GAAG,uBAAa,CAAC,MAAM,CAAC,0BAAwB,CAAC,CAAC;IAEvE,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QAChD,MAAM,GAAG,GAAG,GAAS,EAAE;YACrB,0BAAwB,CAAC,MAAM,CAAC,IAAI,CAClC,uBAAuB,MAAM,CAAC,KAAK,GAAG,EACtC;gBACE,QAAQ,EAAE,MAAM,CAAC,KAAK;aACvB,CACF,CAAC;YAEF,uBAAa,CAAC,WAAW,CAAC;gBACxB,GAAG,MAAM;gBACT,eAAe,EAAE,MAAM,CAAC,kBAAkB;gBAC1C,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;aAC9B,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACrB,GAAG,EAAE,CAAC;IACR,CAAC;IAED,KAAK,CAAC,qBAAqB;QACzB,MAAM,uBAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACK,aAAa,CAAC,MAAqB;QACzC,MAAM,cAAc,GAClB,MAAM,CAAC,WAAW;YAClB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;YAC5B,MAAM,CAAC,cAAc,CAAC;QAExB,OAAO,cAAc;YACnB,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE;YACnD,CAAC,CAAC;gBACE,MAAM,EAA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G,WAAW,CAAC;QACpD,CAAC;QAED,MAAM,OAAO,GAA4B;YACvC,yBAAyB,EAAE;gBACzB,mBAAmB,EAAE,OAAO;gBAC5B,eAAe;aAChB;SACF,CAAC;QAEF,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YAC3B,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,eAAe,CAAC;YAC5C,OAAO,CAAC,kBAAkB,GAAG;gBAC3B,cAAc,EAAE,MAAM,CAAC,eAAe;aACvC,CAAC;QACJ,CAAC;QAED,OAAO;YACL,MAAM,EAAE,8BAA8B;YACtC,OAAO;YACP,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC;IACJ,CAAC;IAEO,eAAe,CACrB,GAAQ,EACR,MAAqB;QAErB,OAAO;YACL,MAAM,EAAE,qBAAqB;YAC7B,OAAO,EAAE;gBACP,GAAG,EAAE,GAAG,CAAC,IAAI;gBACb,OAAO,EAAE,MAAM,CAAC,WAAW;gBAC3B,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE;gBACpC,SAAS,EAAE,MAAM,CAAC,aAAa;gBAC/B,aAAa,EAAE,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE;gBAChD,UAAU,EAAE,MAAM,CAAC,cAAc;gBACjC,UAAU,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE;gBAC1C,aAAa,EAAE,MAAM,CAAC,iBAAiB;gBACvC,MAAM,EAAE,MAAM,CAAC,UAAU;aAC1B;YACD,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC;IACJ,CAAC;;AAzIU,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,eAAM,EAAC,EAAE,CAAC;qCAI4B,8BAAa;GAHvC,wBAAwB,CA0IpC"}
|
|
@@ -1,9 +1,31 @@
|
|
|
1
|
+
import { Timespan } from '@rsdk/common';
|
|
1
2
|
import { LogLevel, LogTimestampFormat } from '@rsdk/logging';
|
|
2
3
|
import { Config } from '../config';
|
|
4
|
+
export declare enum LogOtelProtocol {
|
|
5
|
+
httpProtobuf = "http/protobuf",
|
|
6
|
+
http = "http",
|
|
7
|
+
httpJson = "http/json",
|
|
8
|
+
grpc = "grpc",
|
|
9
|
+
console = "console"
|
|
10
|
+
}
|
|
3
11
|
export declare class LoggingConfig extends Config {
|
|
4
12
|
readonly level: LogLevel;
|
|
5
13
|
readonly redact: string[];
|
|
6
14
|
readonly sync: boolean;
|
|
15
|
+
readonly shutdownTimeout: Timespan;
|
|
16
|
+
readonly forceTransport: boolean;
|
|
17
|
+
readonly httpEndpoint?: URL;
|
|
18
|
+
readonly httpHeaders: Record<string, string>;
|
|
19
|
+
readonly httpTimeout: Timespan;
|
|
20
|
+
readonly httpBatchSize: number;
|
|
21
|
+
readonly httpBatchInterval: Timespan;
|
|
22
|
+
readonly httpMaxRetries: number;
|
|
23
|
+
readonly httpRetryDelay: Timespan;
|
|
24
|
+
readonly httpMaxBufferSize: number;
|
|
25
|
+
readonly httpSilent: boolean;
|
|
7
26
|
readonly otelEnabled: boolean;
|
|
27
|
+
readonly otelEndpoint?: URL;
|
|
28
|
+
readonly otelProtocol?: LogOtelProtocol;
|
|
29
|
+
readonly otelServiceName?: string;
|
|
8
30
|
readonly logTimestampFormat: LogTimestampFormat;
|
|
9
31
|
}
|
|
@@ -9,15 +9,38 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LoggingConfig = void 0;
|
|
12
|
+
exports.LoggingConfig = exports.LogOtelProtocol = void 0;
|
|
13
|
+
const common_1 = require("@rsdk/common");
|
|
13
14
|
const logging_1 = require("@rsdk/logging");
|
|
14
15
|
const config_1 = require("../config");
|
|
15
16
|
const config_const_1 = require("../config/config.const");
|
|
17
|
+
var LogOtelProtocol;
|
|
18
|
+
(function (LogOtelProtocol) {
|
|
19
|
+
LogOtelProtocol["httpProtobuf"] = "http/protobuf";
|
|
20
|
+
LogOtelProtocol["http"] = "http";
|
|
21
|
+
LogOtelProtocol["httpJson"] = "http/json";
|
|
22
|
+
LogOtelProtocol["grpc"] = "grpc";
|
|
23
|
+
LogOtelProtocol["console"] = "console";
|
|
24
|
+
})(LogOtelProtocol || (exports.LogOtelProtocol = LogOtelProtocol = {}));
|
|
16
25
|
let LoggingConfig = class LoggingConfig extends config_1.Config {
|
|
17
26
|
level;
|
|
18
27
|
redact;
|
|
19
28
|
sync;
|
|
29
|
+
shutdownTimeout;
|
|
30
|
+
forceTransport;
|
|
31
|
+
httpEndpoint;
|
|
32
|
+
httpHeaders;
|
|
33
|
+
httpTimeout;
|
|
34
|
+
httpBatchSize;
|
|
35
|
+
httpBatchInterval;
|
|
36
|
+
httpMaxRetries;
|
|
37
|
+
httpRetryDelay;
|
|
38
|
+
httpMaxBufferSize;
|
|
39
|
+
httpSilent;
|
|
20
40
|
otelEnabled;
|
|
41
|
+
otelEndpoint;
|
|
42
|
+
otelProtocol;
|
|
43
|
+
otelServiceName;
|
|
21
44
|
logTimestampFormat;
|
|
22
45
|
};
|
|
23
46
|
exports.LoggingConfig = LoggingConfig;
|
|
@@ -39,17 +62,115 @@ __decorate([
|
|
|
39
62
|
__decorate([
|
|
40
63
|
(0, config_1.Property)('LOG_SYNC', new config_1.BoolParser(), {
|
|
41
64
|
defaultValue: false,
|
|
42
|
-
description: 'Synchronous
|
|
65
|
+
description: 'Synchronous stdout writes. Applies only to in-process stream mode; worker transports (OTEL/HTTP/forced) are always async. https://github.com/pinojs/pino/blob/master/docs/asynchronous.md',
|
|
43
66
|
}),
|
|
44
67
|
__metadata("design:type", Boolean)
|
|
45
68
|
], LoggingConfig.prototype, "sync", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, config_1.Property)('LOG_SHUTDOWN_TIMEOUT', new config_1.TimespanParser(), {
|
|
71
|
+
defaultValue: new common_1.Timespan(1, 's'),
|
|
72
|
+
description: 'Max time to flush buffered worker-transport logs on application shutdown. Raise it when using OTEL: its worker may take longer to flush the last batch',
|
|
73
|
+
}),
|
|
74
|
+
__metadata("design:type", common_1.Timespan)
|
|
75
|
+
], LoggingConfig.prototype, "shutdownTimeout", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, config_1.Property)('LOG_FORCE_TRANSPORT', new config_1.BoolParser(), {
|
|
78
|
+
defaultValue: false,
|
|
79
|
+
description: 'Use worker-based transport even when only stdout is configured (no OTEL/HTTP). Otherwise stdout-only logging stays in-process',
|
|
80
|
+
}),
|
|
81
|
+
__metadata("design:type", Boolean)
|
|
82
|
+
], LoggingConfig.prototype, "forceTransport", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, config_1.Property)('LOG_HTTP_ENDPOINT', new config_1.UrlParser('http:', 'https:'), {
|
|
85
|
+
defaultValue: undefined,
|
|
86
|
+
description: 'URL endpoint for the HTTP logs transport. Transport is enabled when set',
|
|
87
|
+
}),
|
|
88
|
+
__metadata("design:type", URL)
|
|
89
|
+
], LoggingConfig.prototype, "httpEndpoint", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, config_1.Property)('LOG_HTTP_HEADERS', new config_1.StringRecordParser(), {
|
|
92
|
+
defaultValue: {},
|
|
93
|
+
description: 'JSON object of HTTP headers sent by the HTTP logs transport',
|
|
94
|
+
}),
|
|
95
|
+
__metadata("design:type", Object)
|
|
96
|
+
], LoggingConfig.prototype, "httpHeaders", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, config_1.Property)('LOG_HTTP_TIMEOUT', new config_1.TimespanParser(), {
|
|
99
|
+
defaultValue: new common_1.Timespan(2500, 'ms'),
|
|
100
|
+
description: 'Request timeout for the HTTP logs transport',
|
|
101
|
+
}),
|
|
102
|
+
__metadata("design:type", common_1.Timespan)
|
|
103
|
+
], LoggingConfig.prototype, "httpTimeout", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, config_1.Property)('LOG_HTTP_BATCH_SIZE', new config_1.IntParser(), {
|
|
106
|
+
defaultValue: 100,
|
|
107
|
+
description: 'Number of logs flushed per batch by the HTTP logs transport',
|
|
108
|
+
}),
|
|
109
|
+
__metadata("design:type", Number)
|
|
110
|
+
], LoggingConfig.prototype, "httpBatchSize", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
(0, config_1.Property)('LOG_HTTP_BATCH_INTERVAL', new config_1.TimespanParser(), {
|
|
113
|
+
defaultValue: new common_1.Timespan(5, 's'),
|
|
114
|
+
description: 'Max interval between batch flushes of the HTTP logs transport',
|
|
115
|
+
}),
|
|
116
|
+
__metadata("design:type", common_1.Timespan)
|
|
117
|
+
], LoggingConfig.prototype, "httpBatchInterval", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, config_1.Property)('LOG_HTTP_MAX_RETRIES', new config_1.IntParser(), {
|
|
120
|
+
defaultValue: 2,
|
|
121
|
+
description: 'Max retry attempts for a failed HTTP logs batch',
|
|
122
|
+
}),
|
|
123
|
+
__metadata("design:type", Number)
|
|
124
|
+
], LoggingConfig.prototype, "httpMaxRetries", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
(0, config_1.Property)('LOG_HTTP_RETRY_DELAY', new config_1.TimespanParser(), {
|
|
127
|
+
defaultValue: new common_1.Timespan(1, 's'),
|
|
128
|
+
description: 'Base delay between HTTP logs retry attempts',
|
|
129
|
+
}),
|
|
130
|
+
__metadata("design:type", common_1.Timespan)
|
|
131
|
+
], LoggingConfig.prototype, "httpRetryDelay", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
(0, config_1.Property)('LOG_HTTP_MAX_BUFFER_SIZE', new config_1.IntParser(), {
|
|
134
|
+
defaultValue: 100000,
|
|
135
|
+
description: 'Max number of buffered logs before dropping (HTTP logs transport)',
|
|
136
|
+
}),
|
|
137
|
+
__metadata("design:type", Number)
|
|
138
|
+
], LoggingConfig.prototype, "httpMaxBufferSize", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
(0, config_1.Property)('LOG_HTTP_SILENT', new config_1.BoolParser(), {
|
|
141
|
+
defaultValue: false,
|
|
142
|
+
description: 'Suppress internal warnings/errors of the HTTP logs transport',
|
|
143
|
+
}),
|
|
144
|
+
__metadata("design:type", Boolean)
|
|
145
|
+
], LoggingConfig.prototype, "httpSilent", void 0);
|
|
46
146
|
__decorate([
|
|
47
147
|
(0, config_1.Property)('LOG_OTEL_ENABLED', new config_1.BoolParser(), {
|
|
48
148
|
defaultValue: false,
|
|
49
|
-
description: 'Enable OpenTelemetry exporter',
|
|
149
|
+
description: 'Enable OpenTelemetry logs exporter',
|
|
50
150
|
}),
|
|
51
151
|
__metadata("design:type", Boolean)
|
|
52
152
|
], LoggingConfig.prototype, "otelEnabled", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
(0, config_1.Property)('LOG_OTEL_ENDPOINT', new config_1.UrlParser('http:', 'https:'), {
|
|
155
|
+
defaultValue: undefined,
|
|
156
|
+
description: 'OTLP endpoint URL for the OpenTelemetry logs exporter',
|
|
157
|
+
}),
|
|
158
|
+
__metadata("design:type", URL)
|
|
159
|
+
], LoggingConfig.prototype, "otelEndpoint", void 0);
|
|
160
|
+
__decorate([
|
|
161
|
+
(0, config_1.Property)('LOG_OTEL_PROTOCOL', new config_1.EnumParser(LogOtelProtocol), {
|
|
162
|
+
defaultValue: undefined,
|
|
163
|
+
description: 'OTLP exporter protocol for the OpenTelemetry logs. When unset, resolved from standard OTEL_EXPORTER_OTLP_PROTOCOL env (defaults to http/protobuf)',
|
|
164
|
+
}),
|
|
165
|
+
__metadata("design:type", String)
|
|
166
|
+
], LoggingConfig.prototype, "otelProtocol", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
(0, config_1.Property)('LOG_OTEL_SERVICE_NAME', new config_1.StringParser(), {
|
|
169
|
+
defaultValue: undefined,
|
|
170
|
+
description: 'service.name resource attribute for the OpenTelemetry logs. When unset, resolved from standard OTEL env',
|
|
171
|
+
}),
|
|
172
|
+
__metadata("design:type", String)
|
|
173
|
+
], LoggingConfig.prototype, "otelServiceName", void 0);
|
|
53
174
|
__decorate([
|
|
54
175
|
(0, config_1.Property)('LOG_TIMESTAMP_FORMAT', new config_1.EnumParser(logging_1.LogTimestampFormat), {
|
|
55
176
|
defaultValue: logging_1.LogTimestampFormat.isoTime,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.config.js","sourceRoot":"","sources":["../../src/logging/logging.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4E;AAE5E,
|
|
1
|
+
{"version":3,"file":"logging.config.js","sourceRoot":"","sources":["../../src/logging/logging.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAwC;AACxC,2CAA4E;AAE5E,sCAYmB;AACnB,yDAAmD;AAEnD,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,iDAA8B,CAAA;IAC9B,gCAAa,CAAA;IACb,yCAAsB,CAAA;IACtB,gCAAa,CAAA;IACb,sCAAmB,CAAA;AACrB,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAKM,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,eAAM;IAM9B,KAAK,CAAY;IAOjB,MAAM,CAAY;IAOlB,IAAI,CAAW;IAOf,eAAe,CAAY;IAO3B,cAAc,CAAW;IAOzB,YAAY,CAAO;IAMnB,WAAW,CAA0B;IAMrC,WAAW,CAAY;IAMvB,aAAa,CAAU;IAOvB,iBAAiB,CAAY;IAM7B,cAAc,CAAU;IAMxB,cAAc,CAAY;IAO1B,iBAAiB,CAAU;IAM3B,UAAU,CAAW;IAMrB,WAAW,CAAW;IAMtB,YAAY,CAAO;IAOnB,YAAY,CAAmB;IAO/B,eAAe,CAAU;IAMzB,kBAAkB,CAAsB;CAClD,CAAA;AA5HY,sCAAa;AAMf;IALR,IAAA,iBAAQ,EAAC,WAAW,EAAE,IAAI,mBAAU,CAAC,kBAAQ,CAAC,EA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E,QAAQ,CAAC,EAAE;QAC/D,YAAY,EAAE,SAAS;QACvB,WAAW,EAAE,uDAAuD;KACrE,CAAC;8BACsB,GAAG;mDAAC;AAOnB;IALR,IAAA,iBAAQ,EAAC,mBAAmB,EAAE,IAAI,mBAAU,CAAC,eAAe,CAAC,EAAE;QAC9D,YAAY,EAAE,SAAS;QACvB,WAAW,EACT,mJAAmJ;KACtJ,CAAC;;mDACsC;AAO/B;IALR,IAAA,iBAAQ,EAAC,uBAAuB,EAAE,IAAI,qBAAY,EAAE,EAAE;QACrD,YAAY,EAAE,SAAS;QACvB,WAAW,EACT,yGAAyG;KAC5G,CAAC;;sDACgC;AAMzB;IAJR,IAAA,iBAAQ,EAAC,sBAAsB,EAAE,IAAI,mBAAU,CAAC,4BAAkB,CAAC,EAAE;QACpE,YAAY,EAAE,4BAAkB,CAAC,OAAO;QACxC,WAAW,EAAE,sBAAsB;KACpC,CAAC;;yDAC+C;wBA3HtC,aAAa;IAHzB,IAAA,sBAAa,EAAC;QACb,IAAI,EAAE,CAAC,wBAAS,CAAC,cAAc,EAAE,wBAAS,CAAC,OAAO,CAAC;KACpD,CAAC;GACW,aAAa,CA4HzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.13.0-next.0",
|
|
4
4
|
"description": "Nestjs based microservice chassis",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"@rsdk/logging": "*",
|
|
35
35
|
"@rsdk/metadata": "*",
|
|
36
36
|
"@rsdk/nest-tools": "*",
|
|
37
|
+
"pino-http-transport": "^1.0.0",
|
|
37
38
|
"pino-opentelemetry-transport": "^1.0.1",
|
|
38
39
|
"reflect-metadata": "^0.1.12 || ^0.2.0",
|
|
39
40
|
"rxjs": "^7.1.0"
|
|
@@ -45,9 +46,12 @@
|
|
|
45
46
|
"@opentelemetry/exporter-logs-otlp-http": {
|
|
46
47
|
"optional": true
|
|
47
48
|
},
|
|
49
|
+
"pino-http-transport": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
48
52
|
"pino-opentelemetry-transport": {
|
|
49
53
|
"optional": true
|
|
50
54
|
}
|
|
51
55
|
},
|
|
52
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "6efbb4a745c7e9cf44c5c71b6365ffb290820894"
|
|
53
57
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BootstrapException } from '../../../exceptions';
|
|
2
|
+
|
|
3
|
+
export class InvalidStringRecord extends BootstrapException {
|
|
4
|
+
constructor(reason: string, value: unknown, cause?: unknown) {
|
|
5
|
+
super(`Invalid string record: ${reason}`, {
|
|
6
|
+
cause,
|
|
7
|
+
details: { value },
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PropertyParser } from '../../types';
|
|
2
|
+
|
|
3
|
+
import { InvalidStringRecord } from './exception';
|
|
4
|
+
|
|
5
|
+
/** Парсит JSON в плоский объект, проверяя, что все значения — строки. */
|
|
6
|
+
export class StringRecordParser
|
|
7
|
+
implements PropertyParser<Record<string, string>>
|
|
8
|
+
{
|
|
9
|
+
type(): string {
|
|
10
|
+
return 'json(Record<string, string>)';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
description(): string {
|
|
14
|
+
return 'Parses a JSON object whose values are all strings';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
parse(value: unknown): Record<string, string> {
|
|
18
|
+
const parsed = this.toJson(value);
|
|
19
|
+
|
|
20
|
+
if (
|
|
21
|
+
parsed === null ||
|
|
22
|
+
typeof parsed !== 'object' ||
|
|
23
|
+
Array.isArray(parsed)
|
|
24
|
+
) {
|
|
25
|
+
throw new InvalidStringRecord('expected a JSON object', value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result: Record<string, string> = {};
|
|
29
|
+
|
|
30
|
+
for (const [key, item] of Object.entries(parsed)) {
|
|
31
|
+
if (typeof item !== 'string') {
|
|
32
|
+
throw new InvalidStringRecord(
|
|
33
|
+
`value of key <${key}> must be a string, got ${typeof item}`,
|
|
34
|
+
value,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
result[key] = item;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private toJson(value: unknown): unknown {
|
|
45
|
+
if (typeof value !== 'string') {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(value);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw new InvalidStringRecord('value is not valid JSON', value, error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|