Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.
Rust downloadmanagerguihacktoberfesthomebrewlightweightlinuxlinux-distributionlocal-firstmacosmacos-packagemedia-toolboxopen-sourcerustsveltetauritrendingtrending-repositorieswindowswindows-desktopytdlp
feat(debug): implement debug logging and diagnostics export functionality
Tonhod9a788c9c89f
diff --git a/src/lib/stores/debug-store.svelte.ts b/src/lib/stores/debug-store.svelte.tsnew file mode 100644index 00000000..50035472--- /dev/null+++ b/src/lib/stores/debug-store.svelte.ts@@ -0,0 +1,125 @@+import { invoke } from "@tauri-apps/api/core";+import { getVersion } from "@tauri-apps/api/app";++export type LogLevel = "info" | "warn" | "error";+export type LogCategory = "download" | "network" | "auth" | "system" | "convert";++export type DebugLogEntry = {+ id: number;+ timestamp: number;+ level: LogLevel;+ category: LogCategory;+ message: string;+ details?: string;+};++const MAX_ENTRIES = 500;++let nextId = 0;+let enabled = $state(false);+let logs = $state<DebugLogEntry[]>([]);+let panelOpen = $state(false);++export function isDebugEnabled(): boolean {+ return enabled;+}++export function setDebugEnabled(value: boolean) {+ enabled = value;+ if (!value) {+ panelOpen = false;+ }+}++export function isDebugPanelOpen(): boolean {+ return panelOpen;+}++export function setDebugPanelOpen(value: boolean) {+ panelOpen = value;+}++export function toggleDebugPanel() {+ if (!enabled) {+ enabled = true;+ }+ panelOpen = !panelOpen;+}++export function getDebugLogs(): DebugLogEntry[] {+ return logs;+}++export function addLog(+ level: LogLevel,+ category: LogCategory,+ message: string,+ details?: string,+) {+ if (!enabled) return;++ const entry: DebugLogEntry = {+ id: nextId++,+ timestamp: Date.now(),+ level,+ category,+ message,+ details,+ };++ logs = [...logs, entry];++ if (logs.length > MAX_ENTRIES) {+ logs = logs.slice(logs.length - MAX_ENTRIES);+ }+}++export function clearLogs() {+ logs = [];+}++type DependencyStatus = {+ name: string;+ installed: boolean;+ version: string | null;+};++export async function exportDiagnostics(): Promise<string> {+ const lines: string[] = [];+ lines.push("--- OmniGet Diagnostic Report ---");++ try {+ const appVersion = await getVersion();+ lines.push(`Version: ${appVersion}`);+ } catch {+ lines.push("Version: unknown");+ }++ lines.push(`OS: ${navigator.userAgent}`);+ lines.push(`Platform: ${navigator.platform}`);+ lines.push(`Timestamp: ${new Date().toISOString()}`);++ try {+ const deps = await invoke<DependencyStatus[]>("check_dependencies");+ for (const dep of deps) {+ lines.push(`${dep.name}: ${dep.installed ? dep.version ?? "installed" : "not found"}`);+ }+ } catch {+ lines.push("Dependencies: check failed");+ }++ lines.push("");+ lines.push(`--- Activity Log (${logs.length} entries) ---`);++ for (const entry of logs) {+ const time = new Date(entry.timestamp).toLocaleTimeString("en-US", { hour12: false });+ const level = entry.level.toUpperCase().padEnd(5);+ lines.push(`[${time}] ${level} [${entry.category}] ${entry.message}`);+ if (entry.details) {+ lines.push(` > ${entry.details}`);+ }+ }++ lines.push("---");+ return lines.join("\n");+}