+{/if}
diff --git a/src/routes/arr/[id]/logs/+page.server.ts b/src/routes/arr/[id]/logs/+page.server.ts
index 8c8ae41..f4714d7 100644
--- a/src/routes/arr/[id]/logs/+page.server.ts
+++ b/src/routes/arr/[id]/logs/+page.server.ts
@@ -1,8 +1,36 @@
import { error } from '@sveltejs/kit';
import type { ServerLoad } from '@sveltejs/kit';
import { arrInstancesQueries } from '$db/queries/arrInstances.ts';
+import { readFilteredLogs } from '$logger/reader.ts';
+import type { UpgradeJobLog } from '$lib/server/upgrades/types.ts';
-export const load: ServerLoad = ({ params }) => {
+/**
+ * Extract UpgradeJobLog from a DEBUG log entry
+ * DEBUG logs contain the full structured log in the meta field
+ */
+function extractUpgradeJobLog(meta: unknown): UpgradeJobLog | null {
+ if (!meta || typeof meta !== 'object') return null;
+
+ const log = meta as Record;
+
+ // Check for required UpgradeJobLog fields
+ if (
+ typeof log.id === 'string' &&
+ typeof log.instanceId === 'number' &&
+ typeof log.status === 'string' &&
+ log.config &&
+ log.library &&
+ log.filter &&
+ log.selection &&
+ log.results
+ ) {
+ return log as unknown as UpgradeJobLog;
+ }
+
+ return null;
+}
+
+export const load: ServerLoad = async ({ params }) => {
const id = parseInt(params.id || '', 10);
if (isNaN(id)) {
@@ -15,7 +43,35 @@ export const load: ServerLoad = ({ params }) => {
error(404, `Instance not found: ${id}`);
}
+ // Load upgrade job logs for this instance
+ const logs = await readFilteredLogs({
+ source: 'UpgradeJob',
+ instanceId: id,
+ count: 500
+ });
+
+ // Extract full UpgradeJobLog objects from DEBUG entries
+ const upgradeRuns: UpgradeJobLog[] = [];
+ const seenIds = new Set();
+
+ for (const log of logs) {
+ if (log.level === 'DEBUG' && log.meta) {
+ const upgradeLog = extractUpgradeJobLog(log.meta);
+ if (upgradeLog && !seenIds.has(upgradeLog.id)) {
+ seenIds.add(upgradeLog.id);
+ upgradeRuns.push(upgradeLog);
+ }
+ }
+ }
+
+ // Sort by startedAt (newest first)
+ upgradeRuns.sort(
+ (a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime()
+ );
+
return {
- instance
+ instance,
+ logs,
+ upgradeRuns
};
};
diff --git a/src/routes/arr/[id]/logs/+page.svelte b/src/routes/arr/[id]/logs/+page.svelte
index 5fe599c..92095da 100644
--- a/src/routes/arr/[id]/logs/+page.svelte
+++ b/src/routes/arr/[id]/logs/+page.svelte
@@ -1,21 +1,122 @@
{data.instance.name} - Logs - Profilarr
-
-
-
Logs
-
- View sync and activity logs for this {data.instance.type} instance.
-
-
- Logs viewer coming soon...
+
+
+
+
+
Upgrade Logs
+
+ View upgrade job history for this {data.instance.type} instance.
+
+
+
+
+
+
+
+
+
+
+ {stats.total} total runs
+
+ {#if stats.success > 0}
+
+ {stats.success} successful
+
+ {/if}
+ {#if stats.partial > 0}
+
+ {stats.partial} partial
+
+ {/if}
+ {#if stats.failed > 0}
+
+ {stats.failed} failed
+
+ {/if}
+
+
+
+
+ {#each statusFilters as filter}
+
+ {/each}
+
+
+ {#if filteredRuns.length === 0}
+
+
+ {#if data.upgradeRuns.length === 0}
+ No upgrade runs yet. Configure upgrades and run a test to see logs here.
+ {:else}
+ No runs match the selected filter.
+ {/if}
+
+
+ {:else}
+
+ {#each filteredRuns as run, index (run.id)}
+
+ {/each}
+