mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
* Add trace logging and tighten daemon log defaults * Clean up daemon trace logging shape * Clean up daemon trace logging * Route provider turn-id checks through shared helper * Fix supervisor log config test paths on Windows * Expect resolved supervisor log path on Windows
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import path from "node:path";
|
|
|
|
import type { loadPersistedConfig } from "../src/server/persisted-config.js";
|
|
|
|
const DEFAULT_DAEMON_LOG_FILENAME = "daemon.log";
|
|
const DEFAULT_LOG_ROTATE_SIZE = "10m";
|
|
const DEFAULT_LOG_ROTATE_MAX_FILES = 3;
|
|
|
|
export function resolveSupervisorLogFile(
|
|
paseoHome: string,
|
|
persistedConfig: ReturnType<typeof loadPersistedConfig>,
|
|
env: NodeJS.ProcessEnv = process.env,
|
|
) {
|
|
const configuredFile = persistedConfig.log?.file;
|
|
const configuredPath = configuredFile?.path;
|
|
const envRotateSize = env.PASEO_LOG_ROTATE_SIZE?.trim();
|
|
const envRotateMaxFiles = parseOptionalPositiveInteger(env.PASEO_LOG_ROTATE_COUNT);
|
|
let logPath = path.join(paseoHome, DEFAULT_DAEMON_LOG_FILENAME);
|
|
if (configuredPath) {
|
|
logPath = path.isAbsolute(configuredPath)
|
|
? configuredPath
|
|
: path.resolve(paseoHome, configuredPath);
|
|
}
|
|
|
|
return {
|
|
path: logPath,
|
|
rotate: {
|
|
maxSize: configuredFile?.rotate?.maxSize ?? envRotateSize ?? DEFAULT_LOG_ROTATE_SIZE,
|
|
maxFiles:
|
|
configuredFile?.rotate?.maxFiles ?? envRotateMaxFiles ?? DEFAULT_LOG_ROTATE_MAX_FILES,
|
|
},
|
|
};
|
|
}
|
|
|
|
function parseOptionalPositiveInteger(value: string | undefined): number | undefined {
|
|
if (value === undefined) {
|
|
return undefined;
|
|
}
|
|
|
|
const parsed = Number.parseInt(value.trim(), 10);
|
|
return Number.isInteger(parsed) && parsed > 0 ? parsed : undefined;
|
|
}
|