A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode,DeepSeek Harness and more. Only official website: ccswitch.io
Rust ai-toolsclaude-codecodexdeepseek-harnessdesktop-appgrokgrokbuildhermeskimi-codemcpopen-sourceopencodepiprovider-managementrustskillsskills-managementtauriwsl-support
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "@/lib/toast";
import { Switch } from "@/components/ui/switch";
import { Label } from "@/components/ui/label";
import { HelpTip } from "@/components/ui/help-tip";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { settingsApi, type LogConfig } from "@/lib/api/settings";
const LOG_LEVELS = ["error", "warn", "info", "debug", "trace"] as const;
export function LogConfigPanel() {
const { t } = useTranslation();
const [config, setConfig] = useState<LogConfig>({
enabled: true,
level: "info",
});
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
settingsApi
.getLogConfig()
.then(setConfig)
.catch((e) => console.error("Failed to load log config:", e))
.finally(() => setIsLoading(false));
}, []);
const handleChange = async (updates: Partial<LogConfig>) => {
const newConfig = { ...config, ...updates };
setConfig(newConfig);
try {
await settingsApi.setLogConfig(newConfig);
} catch (e) {
console.error("Failed to save log config:", e);
toast.error(String(e));
setConfig(config);
}
};
if (isLoading) return null;
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<div className="flex items-center gap-1">
<Label htmlFor="diagnostic-log-enabled">
{t("settings.advanced.logConfig.enabled")}
</Label>
<HelpTip title={t("settings.advanced.logConfig.enabled")}>
{t("settings.advanced.logConfig.enabledDescription")}
</HelpTip>
</div>
<Switch
id="diagnostic-log-enabled"
checked={config.enabled}
onCheckedChange={(checked) => handleChange({ enabled: checked })}
/>
</div>
<div className="flex items-center justify-between">
<div className="flex items-center gap-1">
<Label htmlFor="diagnostic-log-level">
{t("settings.advanced.logConfig.level")}
</Label>
<HelpTip title={t("settings.advanced.logConfig.level")}>
<div className="space-y-1.5">
<p>{t("settings.advanced.logConfig.levelDescription")}</p>
{LOG_LEVELS.map((level) => (
<p key={level}>
<span className="font-mono">{level}</span> —{" "}
{t(`settings.advanced.logConfig.levelDesc.${level}`)}
</p>
))}
</div>
</HelpTip>
</div>
<Select
value={config.level}
disabled={!config.enabled}
onValueChange={(value) =>
handleChange({ level: value as LogConfig["level"] })
}
>
<SelectTrigger id="diagnostic-log-level" className="w-[120px]">
<SelectValue />
</SelectTrigger>
<SelectContent>
{LOG_LEVELS.map((level) => (
<SelectItem key={level} value={level}>
{t(`settings.advanced.logConfig.levels.${level}`)}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>
);
}