Skip to content

Commit 4a8ecda

Browse files
Refactor logging implementation and update imports
- Moved the logger instance to a new `logger.ts` file for better organization and reusability. - Updated import paths in `index.ts`, `index.test.ts`, and `schedules.ts` to reference the new logger module. - Ensured that the logger is consistently used across the application, improving maintainability and clarity. These changes streamline the logging setup and enhance code structure.
1 parent 63945a5 commit 4a8ecda

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

workers/main/src/configs/schedules.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Client } from '@temporalio/client';
22

3-
import { logger } from '../index';
3+
import { logger } from '../logger';
44
import { weeklyFinancialReportsWorkflow } from '../workflows';
55
import { workerConfig } from './worker';
66

workers/main/src/index.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
22

3-
import { handleRunError, logger } from './index';
3+
import { handleRunError } from './index';
4+
import { logger } from './logger';
45

56
describe('handleRunError', () => {
67
let processExitSpy: ReturnType<typeof vi.spyOn>;

workers/main/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { Client, Connection } from '@temporalio/client';
2-
import { DefaultLogger, NativeConnection, Worker } from '@temporalio/worker';
2+
import { NativeConnection, Worker } from '@temporalio/worker';
33

44
import * as activities from './activities';
55
import { validateEnv } from './common/utils';
66
import { setupWeeklyReportSchedule } from './configs/schedules';
77
import { temporalConfig } from './configs/temporal';
88
import { workerConfig } from './configs/worker';
9+
import { logger } from './logger';
910

10-
export const logger = new DefaultLogger('ERROR');
11+
export { logger };
1112

1213
validateEnv();
1314

workers/main/src/logger.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { DefaultLogger } from '@temporalio/worker';
2+
3+
/**
4+
* Shared logger instance for the worker
5+
* Using ERROR level to reduce noise in production
6+
*/
7+
export const logger = new DefaultLogger('ERROR');

0 commit comments

Comments
 (0)