fix(logging): apply cli log level on second-instance commands

This commit is contained in:
2026-02-28 20:07:45 -08:00
parent 55c577e911
commit 4309e0dec3
8 changed files with 54 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import {
} from './dependencies';
export interface CliCommandRuntimeServiceContext {
setLogLevel?: (level: NonNullable<CliArgs['logLevel']>) => void;
getSocketPath: () => string;
setSocketPath: (socketPath: string) => void;
getClient: CliCommandRuntimeServiceDepsParams['mpv']['getClient'];
@@ -55,6 +56,7 @@ function createCliCommandDepsFromContext(
context: CliCommandRuntimeServiceContext & CliCommandRuntimeServiceContextHandlers,
): CliCommandRuntimeServiceDepsParams {
return {
setLogLevel: context.setLogLevel,
mpv: {
getSocketPath: context.getSocketPath,
setSocketPath: context.setSocketPath,

View File

@@ -112,6 +112,7 @@ export interface AnkiJimakuIpcRuntimeServiceDepsParams {
}
export interface CliCommandRuntimeServiceDepsParams {
setLogLevel?: CliCommandDepsRuntimeOptions['setLogLevel'];
mpv: {
getSocketPath: CliCommandDepsRuntimeOptions['mpv']['getSocketPath'];
setSocketPath: CliCommandDepsRuntimeOptions['mpv']['setSocketPath'];
@@ -254,6 +255,7 @@ export function createCliCommandRuntimeServiceDeps(
params: CliCommandRuntimeServiceDepsParams,
): CliCommandDepsRuntimeOptions {
return {
setLogLevel: params.setLogLevel,
mpv: {
getSocketPath: params.mpv.getSocketPath,
setSocketPath: params.mpv.setSocketPath,

View File

@@ -2,6 +2,7 @@ import type { CliArgs } from '../../cli/args';
import type { CliCommandContextFactoryDeps } from './cli-command-context';
export function createBuildCliCommandContextDepsHandler(deps: {
setLogLevel?: (level: NonNullable<CliArgs['logLevel']>) => void;
getSocketPath: () => string;
setSocketPath: (socketPath: string) => void;
getMpvClient: CliCommandContextFactoryDeps['getMpvClient'];
@@ -45,6 +46,7 @@ export function createBuildCliCommandContextDepsHandler(deps: {
logError: (message: string, err: unknown) => void;
}) {
return (): CliCommandContextFactoryDeps => ({
setLogLevel: deps.setLogLevel,
getSocketPath: deps.getSocketPath,
setSocketPath: deps.setSocketPath,
getMpvClient: deps.getMpvClient,

View File

@@ -10,6 +10,7 @@ type CliCommandContextMainState = {
export function createBuildCliCommandContextMainDepsHandler(deps: {
appState: CliCommandContextMainState;
setLogLevel?: (level: NonNullable<CliArgs['logLevel']>) => void;
texthookerService: CliCommandContextFactoryDeps['texthookerService'];
getResolvedConfig: () => { texthooker?: { openBrowser?: boolean } };
openExternal: (url: string) => Promise<unknown>;
@@ -51,6 +52,7 @@ export function createBuildCliCommandContextMainDepsHandler(deps: {
logError: (message: string, err: unknown) => void;
}) {
return (): CliCommandContextFactoryDeps => ({
setLogLevel: deps.setLogLevel,
getSocketPath: () => deps.appState.mpvSocketPath,
setSocketPath: (socketPath: string) => {
deps.appState.mpvSocketPath = socketPath;

View File

@@ -7,6 +7,7 @@ import type {
type MpvClientLike = CliCommandRuntimeServiceContext['getClient'] extends () => infer T ? T : never;
export type CliCommandContextFactoryDeps = {
setLogLevel?: (level: NonNullable<CliArgs['logLevel']>) => void;
getSocketPath: () => string;
setSocketPath: (socketPath: string) => void;
getMpvClient: () => MpvClientLike;
@@ -54,6 +55,7 @@ export function createCliCommandContext(
deps: CliCommandContextFactoryDeps,
): CliCommandRuntimeServiceContext & CliCommandRuntimeServiceContextHandlers {
return {
setLogLevel: deps.setLogLevel,
getSocketPath: deps.getSocketPath,
setSocketPath: deps.setSocketPath,
getClient: deps.getMpvClient,