mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-09-21 05:16:20 -07:00
Fix Windows mpv logging and add log export (#88)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
export type SharedLogLevel = 'debug' | 'info' | 'warn' | 'error';
|
||||
|
||||
function hasOption(args: readonly string[], option: string): boolean {
|
||||
return args.some((arg) => arg === option || arg.startsWith(`${option}=`));
|
||||
}
|
||||
|
||||
export function buildMpvMsgLevel(logLevel: SharedLogLevel): string {
|
||||
return `all=warn,subminer=${logLevel}`;
|
||||
}
|
||||
|
||||
export function buildMpvLoggingArgs(
|
||||
logLevel: SharedLogLevel,
|
||||
logPath: string,
|
||||
existingArgs: readonly string[] = [],
|
||||
): string[] {
|
||||
if (!logPath.trim()) {
|
||||
return [];
|
||||
}
|
||||
const args: string[] = [];
|
||||
if (!hasOption(existingArgs, '--log-file')) {
|
||||
args.push(`--log-file=${logPath}`);
|
||||
}
|
||||
if (!hasOption(existingArgs, '--msg-level')) {
|
||||
args.push(`--msg-level=${buildMpvMsgLevel(logLevel)}`);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
Reference in New Issue
Block a user