mirror of
https://github.com/Alvin-Zilverstand/Twitter-X-Media-Batch-Downloader.git
synced 2026-12-01 10:31:24 +01:00
v5.0.1
This commit is contained in:
1 parent
70f5088574
commit
9c269bc8f2
31 files changed
+2579
-1487
No files matched your search
@@ -1,7 +1,9 @@
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import { Trash2, Copy, Check } from "lucide-react";
|
||||
import { Trash2, Copy, CircleCheck, FileDown } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { logger, type LogEntry } from "@/lib/logger";
|
||||
import { ExportFailedLogs } from "../../wailsjs/go/main/App";
|
||||
import { toastWithSound as toast } from "@/lib/toast-with-sound";
|
||||
const levelColors: Record<string, string> = {
|
||||
info: "text-blue-500",
|
||||
success: "text-green-500",
|
||||
@@ -21,6 +23,7 @@ export function DebugLoggerPage() {
|
||||
const [logs, setLogs] = useState<LogEntry[]>(() => logger.getLogs());
|
||||
const [copied, setCopied] = useState(false);
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
const failedLogs = logs.filter((log) => log.level === "error");
|
||||
useEffect(() => {
|
||||
const unsubscribe = logger.subscribe(() => {
|
||||
setLogs(logger.getLogs());
|
||||
@@ -50,22 +53,49 @@ export function DebugLoggerPage() {
|
||||
console.error("Failed to copy logs:", err);
|
||||
}
|
||||
};
|
||||
const handleExportFailed = async () => {
|
||||
if (failedLogs.length === 0) {
|
||||
toast.info("No failed logs to export");
|
||||
return;
|
||||
}
|
||||
const lines = [
|
||||
`Failed Logs Report - ${new Date().toLocaleString()}`,
|
||||
"-".repeat(50),
|
||||
"",
|
||||
...failedLogs.map((log) => `[${formatTime(log.timestamp)}] [${log.level}] ${log.message}`),
|
||||
"",
|
||||
];
|
||||
try {
|
||||
const path = await ExportFailedLogs(lines.join("\n"));
|
||||
if (path) {
|
||||
toast.success(`Exported ${failedLogs.length} failed log${failedLogs.length === 1 ? "" : "s"}`);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error("Failed to export logs:", error);
|
||||
toast.error(`Failed to export logs: ${error}`);
|
||||
}
|
||||
};
|
||||
return (<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-bold">Debug Logs</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button variant="outline" size="sm" onClick={handleExportFailed} className="gap-1.5">
|
||||
<FileDown className="h-4 w-4"/>
|
||||
Export Failed
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" onClick={handleCopy} disabled={logs.length === 0} className="gap-1.5">
|
||||
{copied ? <Check className="h-4 w-4"/> : <Copy className="h-4 w-4"/>}
|
||||
{copied ? <CircleCheck className="h-4 w-4"/> : <Copy className="h-4 w-4"/>}
|
||||
Copy
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" onClick={handleClear} className="gap-1.5">
|
||||
<Button variant="destructive" size="sm" onClick={handleClear} disabled={logs.length === 0} className="gap-1.5">
|
||||
<Trash2 className="h-4 w-4"/>
|
||||
Clear
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ref={scrollRef} className="h-[calc(100vh-220px)] overflow-y-auto bg-muted/50 rounded-md p-3 font-mono text-xs">
|
||||
<div ref={scrollRef} className="h-[calc(100vh-220px)] overflow-y-auto rounded-lg bg-muted/50 p-4 font-mono text-xs">
|
||||
{logs.length === 0 ? (<p className="text-muted-foreground lowercase">no logs yet...</p>) : (logs.map((log, i) => (<div key={i} className="flex gap-2 py-0.5">
|
||||
<span className="text-muted-foreground shrink-0">
|
||||
[{formatTime(log.timestamp)}]
|
||||
|
||||
Reference in new issue
Block a user