@xrystal/core 3.3.0 → 3.3.1
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
|
@@ -42,14 +42,14 @@ export default class LoggerService {
|
|
|
42
42
|
winston.addColors(customColors);
|
|
43
43
|
}
|
|
44
44
|
load = async (config) => {
|
|
45
|
-
this.serviceName = config
|
|
46
|
-
this.environment = config
|
|
47
|
-
this.kafkaTopic = config
|
|
45
|
+
this.serviceName = config?.serviceName || "service";
|
|
46
|
+
this.environment = config?.env || "dev";
|
|
47
|
+
this.kafkaTopic = config?.kafkaTopic || "logs";
|
|
48
48
|
this.winstonLoader({
|
|
49
|
-
loadPath: config
|
|
50
|
-
loggerLevel: config
|
|
49
|
+
loadPath: config?.loadPath || "./logs",
|
|
50
|
+
loggerLevel: config?.loggerLevel || "debug"
|
|
51
51
|
});
|
|
52
|
-
const rawBrokers = config
|
|
52
|
+
const rawBrokers = config?.kafkaBrokers;
|
|
53
53
|
const brokers = rawBrokers ? String(rawBrokers).split(',').map((b) => b.trim()) : [];
|
|
54
54
|
if (brokers.length > 0) {
|
|
55
55
|
try {
|
|
@@ -64,12 +64,11 @@ export default class LoggerService {
|
|
|
64
64
|
this.kafkaProducer = kafka.producer({ createPartitioner: Partitioners.LegacyPartitioner });
|
|
65
65
|
await this.kafkaProducer.connect();
|
|
66
66
|
this.isKafkaReady = true;
|
|
67
|
-
this.winston.info('Logger connected to Kafka
|
|
67
|
+
this.winston.info('Logger connected to Kafka');
|
|
68
68
|
}
|
|
69
69
|
catch (err) {
|
|
70
|
-
console.error(`
|
|
70
|
+
console.error(`Kafka error: ${err.message}`);
|
|
71
71
|
this.isKafkaReady = false;
|
|
72
|
-
this.kafkaProducer = null;
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
};
|