Fix Windows mpv logging and add log export (#88)

This commit is contained in:
2026-05-26 00:31:38 -07:00
committed by GitHub
parent 43ebc7d371
commit 11c196821d
150 changed files with 2748 additions and 582 deletions
+22 -2
View File
@@ -1,5 +1,11 @@
import {
appendLogLine,
applyLogFileTogglesToEnv,
DEFAULT_LOG_ROTATION,
isLogFileEnabled,
normalizeLogRotation,
type LogFileToggles,
type LogRotation,
resolveDefaultLogFilePath as resolveSharedDefaultLogFilePath,
} from './shared/log-files';
@@ -24,10 +30,11 @@ const LEVEL_PRIORITY: Record<LogLevel, number> = {
error: 40,
};
const DEFAULT_LOG_LEVEL: LogLevel = 'info';
const DEFAULT_LOG_LEVEL: LogLevel = 'warn';
let cliLogLevel: LogLevel | undefined;
let configLogLevel: LogLevel | undefined;
let configLogRotation: LogRotation = DEFAULT_LOG_ROTATION;
function pad(value: number): string {
return String(value).padStart(2, '0');
@@ -76,6 +83,15 @@ export function setLogLevel(level: string | undefined, source: LogLevelSource =
}
}
export function setLogRotation(rotation: unknown): void {
configLogRotation = normalizeLogRotation(rotation) ?? DEFAULT_LOG_ROTATION;
process.env.SUBMINER_LOG_ROTATION = String(configLogRotation);
}
export function setLogFileToggles(files: Partial<LogFileToggles> | undefined): void {
applyLogFileTogglesToEnv(files);
}
function normalizeError(error: Error): { message: string; stack?: string } {
return {
message: error.message,
@@ -124,12 +140,16 @@ export function resolveDefaultLogFilePath(options?: {
platform?: NodeJS.Platform;
homeDir?: string;
appDataDir?: string;
rotation?: unknown;
}): string {
return resolveSharedDefaultLogFilePath('app', options);
}
function appendToLogFile(line: string): void {
appendLogLine(resolveLogFilePath(), line);
if (!isLogFileEnabled('app')) {
return;
}
appendLogLine(resolveLogFilePath(), line, { rotation: configLogRotation });
}
function emit(level: LogLevel, scope: string, message: string, meta: unknown[]): void {