feat(logs): reverse log order so the newest logs always display at the top

This commit is contained in:
2026-06-14 15:00:03 -07:00
parent e0354d969e
commit 26b4c53633

View File

@@ -112,20 +112,26 @@ export default function LogsPage() {
} catch {} } catch {}
} }
const reverseLogs = (str: string) =>
str.trim().split("\n").reverse().join("\n");
if (typeof obj === "object" && obj !== null) { if (typeof obj === "object" && obj !== null) {
if (obj.services) { if (obj.services) {
out = Object.values(obj.services) out = Object.values(obj.services)
.map((s: any) => s.logs) .map((s: any) => reverseLogs(s.logs || ""))
.join("\n\n"); .join("\n\n");
} else if (obj.log) { } else if (obj.log) {
out = obj.log; out = reverseLogs(obj.log);
} else if (obj.logs) { } else if (obj.logs) {
out = obj.logs; out = reverseLogs(obj.logs);
} else { } else {
out = JSON.stringify(obj, null, 2); out = JSON.stringify(obj, null, 2);
} }
} else { } else {
out = String(obj || d.error || "No logs available."); out = String(obj || d.error || "No logs available.");
if (typeof obj === "string") {
out = reverseLogs(out);
}
} }
setLogs(out || "No logs available."); setLogs(out || "No logs available.");