diff --git a/services/platform-service/src/lib/cosmos-init.test.ts b/services/platform-service/src/lib/cosmos-init.test.ts index 34afbe35..f9e1eb22 100644 --- a/services/platform-service/src/lib/cosmos-init.test.ts +++ b/services/platform-service/src/lib/cosmos-init.test.ts @@ -38,14 +38,14 @@ describe('initCosmosIfNeeded', () => { vi.stubEnv('NODE_ENV', 'test'); cosmosMock.initializeAllContainers.mockResolvedValue(undefined); - const infoSpy = vi.spyOn(console, 'info').mockImplementation(() => {}); + const writeSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true); const { initCosmosIfNeeded } = await import('./cosmos-init.js'); await initCosmosIfNeeded(); expect(cosmosMock.registerContainers).toHaveBeenCalledOnce(); expect(cosmosMock.initializeAllContainers).toHaveBeenCalledOnce(); - expect(infoSpy).toHaveBeenCalledWith('[platform-service] Cosmos containers ensured'); + expect(writeSpy).toHaveBeenCalledWith('[platform-service] Cosmos containers ensured\n'); }); it('logs warning when initialization fails', async () => { @@ -55,13 +55,13 @@ describe('initCosmosIfNeeded', () => { vi.stubEnv('NODE_ENV', 'test'); cosmosMock.initializeAllContainers.mockRejectedValue(new Error('boom')); - const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); + const writeSpy = vi.spyOn(process.stderr, 'write').mockImplementation(() => true); const { initCosmosIfNeeded } = await import('./cosmos-init.js'); await initCosmosIfNeeded(); expect(cosmosMock.registerContainers).toHaveBeenCalledOnce(); expect(cosmosMock.initializeAllContainers).toHaveBeenCalledOnce(); - expect(warnSpy).toHaveBeenCalledWith('[platform-service] Cosmos init failed: boom'); + expect(writeSpy).toHaveBeenCalledWith('[platform-service] Cosmos init failed: boom\n'); }); }); diff --git a/services/platform-service/src/lib/cosmos-init.ts b/services/platform-service/src/lib/cosmos-init.ts index cde54493..2806237d 100644 --- a/services/platform-service/src/lib/cosmos-init.ts +++ b/services/platform-service/src/lib/cosmos-init.ts @@ -113,11 +113,9 @@ export async function initCosmosIfNeeded(): Promise { try { await initializeAllContainers(); - // eslint-disable-next-line no-console - console.info('[platform-service] Cosmos containers ensured'); + process.stdout.write('[platform-service] Cosmos containers ensured\n'); } catch (err) { const msg = err instanceof Error ? err.message : String(err); - // eslint-disable-next-line no-console - console.warn(`[platform-service] Cosmos init failed: ${msg}`); + process.stderr.write(`[platform-service] Cosmos init failed: ${msg}\n`); } } diff --git a/services/platform-service/src/server.ts b/services/platform-service/src/server.ts index 1457581e..807071ce 100644 --- a/services/platform-service/src/server.ts +++ b/services/platform-service/src/server.ts @@ -90,7 +90,9 @@ await initCosmosIfNeeded(); await loadProductCache(); // Seed default feature flags (idempotent, best-effort) -seedDefaultFlags({ info: (msg: string) => console.log(`[flags-seed] ${msg}`) }).catch(() => {}); +seedDefaultFlags({ info: (msg: string) => process.stdout.write(`[flags-seed] ${msg}\n`) }).catch( + () => {} +); const app = await createServiceApp({ name: 'platform-service',