Files
flights_web/src/observability/logger/root.ts
T
gnezim 1facfd8050
Deploy / build-and-deploy (push) Failing after 5s
Fix runtime rendering: Outlet, process guards, env defaults
Three root causes of blank page:
1. Modern.js layouts use <Outlet /> not {children} for nested routes
2. process.env not available in browser — guard with typeof checks
3. getEnv() schema required all fields — add defaults for browser context

Also: add source.entriesDir, runtime.router to modern.config.ts,
disable SSR temporarily until the SSR server build alias issue is
resolved (framework-level @_modern_js_src resolution).
2026-04-15 15:24:32 +03:00

42 lines
1.2 KiB
TypeScript

import type { Logger, LogTransport } from "./types.js";
import { LoggerImpl } from "./logger-impl.js";
import { ConsoleTransport } from "./console-transport.js";
import { JsonLinesHttpTransport } from "./json-lines-transport.js";
let cached: Logger | undefined;
/**
* Creates or returns the cached root logger. In development, uses
* ConsoleTransport. In other envs, uses JsonLinesHttpTransport if
* LOGS_ENDPOINT is set, otherwise falls back to console.
*/
export function createRootLogger(): Logger {
if (cached) return cached;
const env =
typeof process !== "undefined" ? process.env["NODE_ENV"] ?? "development" : "development";
const logsEndpoint =
typeof process !== "undefined" ? process.env["LOGS_ENDPOINT"] : undefined;
let transport: LogTransport;
if (env === "development" || !logsEndpoint) {
transport = new ConsoleTransport();
} else {
transport = new JsonLinesHttpTransport({
endpoint: logsEndpoint,
batchSize: 50,
flushIntervalMs: 5000,
maxBufferSize: 500,
});
}
cached = new LoggerImpl(transport);
return cached;
}
/** Test-only: clears the cached root logger. */
export function __resetRootLoggerForTests(): void {
cached = undefined;
}