@xrystal/core 3.17.8 → 3.18.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/package.json
CHANGED
|
@@ -28,7 +28,7 @@ export default class ConfigsService {
|
|
|
28
28
|
systemStaticFolderPath: path.resolve(rawConfigs.rootFolderPath, this.publicFolderName),
|
|
29
29
|
systemLoggerLayer: process.env.SYSTEM_LOGGER_LAYER,
|
|
30
30
|
kafkaBrokers: process.env?.KAFKA_BROKERS,
|
|
31
|
-
kafkaLogsTopic: kafkaLogsTopic,
|
|
31
|
+
kafkaLogsTopic: this.kafkaLogsTopic,
|
|
32
32
|
baseApiUri: process.env.HTTPS === 'true' ? process.env.SYSTEM_HTTPS_BASE_API_URI : process.env.SYSTEM_BASE_API_URI,
|
|
33
33
|
port: process.env.PORT || rawConfigs.port || 3000,
|
|
34
34
|
internalSecret: process.env.INTERNAL_SECRET,
|
|
@@ -32,7 +32,7 @@ export default class LoggerService implements IService {
|
|
|
32
32
|
private getTracingFormat;
|
|
33
33
|
private getConsoleFormat;
|
|
34
34
|
runWithId: <T>(id: string, callback: () => T) => T;
|
|
35
|
-
|
|
35
|
+
logToKafka(info: any): Promise<void>;
|
|
36
36
|
log(level: LoggerLayerEnum, message: any, payload?: any, code?: string | number): void;
|
|
37
37
|
log(options: LogOptions): void;
|
|
38
38
|
}
|
|
@@ -64,17 +64,13 @@ export default class LoggerService {
|
|
|
64
64
|
createPartitioner: Partitioners.DefaultPartitioner,
|
|
65
65
|
retry: { initialRetryTime: 500, retries: 5 }
|
|
66
66
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
setTimeout(connectKafka, 10000);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
connectKafka();
|
|
67
|
+
try {
|
|
68
|
+
await this.kafkaProducer.connect();
|
|
69
|
+
this.isKafkaReady = true;
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
this.isKafkaReady = false;
|
|
73
|
+
}
|
|
78
74
|
}
|
|
79
75
|
this.winstonLoader({
|
|
80
76
|
loadPath: config?.loadPath,
|
|
@@ -155,6 +151,7 @@ export default class LoggerService {
|
|
|
155
151
|
return;
|
|
156
152
|
try {
|
|
157
153
|
const { id, level, message, payload, code } = info;
|
|
154
|
+
console.log('geldii', this.kafkaTopic);
|
|
158
155
|
await this.kafkaProducer.send({
|
|
159
156
|
topic: this.kafkaTopic,
|
|
160
157
|
messages: [{
|
|
@@ -169,7 +166,7 @@ export default class LoggerService {
|
|
|
169
166
|
env: this.#configsService.all.env
|
|
170
167
|
}, this.safeReplacer)
|
|
171
168
|
}],
|
|
172
|
-
acks:
|
|
169
|
+
acks: 1
|
|
173
170
|
});
|
|
174
171
|
}
|
|
175
172
|
catch (err) {
|
|
@@ -181,6 +178,7 @@ export default class LoggerService {
|
|
|
181
178
|
const { level, message, payload, code } = isObj
|
|
182
179
|
? arg1
|
|
183
180
|
: { level: arg1, message: arg2, payload: arg3, code: arg4 };
|
|
184
|
-
|
|
181
|
+
const levelKey = typeof level === 'string' ? level.toLowerCase() : LoggerLayerEnum[level].toLowerCase();
|
|
182
|
+
this.winston.log(levelKey, message, { payload, code });
|
|
185
183
|
}
|
|
186
184
|
}
|