@xrystal/core 3.2.7 → 3.3.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xrystal/core",
3
- "version": "3.2.7",
3
+ "version": "3.3.0",
4
4
  "description": "Project core for xrystal",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -44,7 +44,7 @@
44
44
  "dev": "tsx watch --env-file=../infrastructer/x/environments/.global.env --env-file=../infrastructer/x/environments/.dev.env --include \"./source/**/*.ts\" --include \"./x\" --exclude node_modules --exclude x/ts-build source/index.ts",
45
45
  "lint": "eslint .",
46
46
  "build": "./node_modules/.bin/tsc",
47
- "start": "node ./x/ts-build/index.js",
47
+ "start": "tsx --env-file=../infrastructer/x/environments/.global.env --env-file=../infrastructer/x/environments/.dev.env --include \"./source/**/*.ts\" --include \"./x\" --exclude node_modules --exclude x/ts-build source/index.ts",
48
48
  "webpack-dev": "node --loader ts-node/esm node_modules/webpack-dev-server/bin/webpack-dev-server --config ./x/webpack/webpack.config.dev.ts",
49
49
  "webpack-prod": "node --loader ts-node/esm node_modules/webpack-cli/bin/cli.js --config ./x/webpack/webpack.config.prod.ts"
50
50
  },
@@ -2,6 +2,7 @@ import winston from 'winston';
2
2
  import 'winston-daily-rotate-file';
3
3
  interface CustomLogger extends winston.Logger {
4
4
  critical: winston.LeveledLogMethod;
5
+ http: winston.LeveledLogMethod;
5
6
  }
6
7
  export default class LoggerService {
7
8
  private serviceName;
@@ -42,18 +42,19 @@ export default class LoggerService {
42
42
  winston.addColors(customColors);
43
43
  }
44
44
  load = async (config) => {
45
- this.serviceName = config.serviceName;
46
- this.environment = config.env;
47
- this.kafkaTopic = config.kafkaTopic;
45
+ this.serviceName = config.serviceName || "unknown";
46
+ this.environment = config.env || "development";
47
+ this.kafkaTopic = config.kafkaTopic || "logs";
48
48
  this.winstonLoader({
49
- loadPath: config.loadPath,
50
- loggerLevel: config.loggerLevel
49
+ loadPath: config.loadPath || "./logs",
50
+ loggerLevel: config.loggerLevel || "debug"
51
51
  });
52
- const brokers = config.kafkaBrokers ? config.kafkaBrokers.split(',').map((b) => b.trim()) : [];
52
+ const rawBrokers = config.kafkaBrokers || "";
53
+ const brokers = rawBrokers ? String(rawBrokers).split(',').map((b) => b.trim()) : [];
53
54
  if (brokers.length > 0) {
54
55
  try {
55
56
  const kafka = new Kafka({
56
- clientId: config.serviceName,
57
+ clientId: this.serviceName,
57
58
  brokers: brokers,
58
59
  retry: {
59
60
  initialRetryTime: 100,
@@ -66,7 +67,7 @@ export default class LoggerService {
66
67
  this.winston.info('Logger connected to Kafka successfully');
67
68
  }
68
69
  catch (err) {
69
- console.error(`[LoggerService] Kafka connection failed: ${err.message}. Logging will continue only to files/console.`);
70
+ console.error(`[LoggerService] Kafka connection failed: ${err.message}`);
70
71
  this.isKafkaReady = false;
71
72
  this.kafkaProducer = null;
72
73
  }
@@ -124,7 +125,6 @@ export default class LoggerService {
124
125
  }
125
126
  catch (err) {
126
127
  this.isKafkaReady = false;
127
- console.error('Kafka send error, disabling Kafka logging temporarily:', err);
128
128
  }
129
129
  }
130
130
  }