Skip to content

Commit

Permalink
fix: Add logger for logging errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun-KumarH committed Mar 20, 2024
1 parent be48e9e commit 48d6d2c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/start.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { Worker } from './worker.js';
import { createServiceConfig } from '@restorecommerce/service-config';
import { createLogger } from '@restorecommerce/logger';

// cfg and logger
const cfg = createServiceConfig(process.cwd());
const loggerCfg = cfg.get('logger');
loggerCfg.esTransformer = (msg) => {
msg.fields = JSON.stringify(msg.fields);
return msg;
};
const logger = createLogger(loggerCfg);

const worker = new Worker();
const logger = worker.logger;
worker.start().then().catch((err) => {
logger.error('startup error', err);
process.exit(1);
Expand Down

0 comments on commit 48d6d2c

Please sign in to comment.