feat(ui): add structured JSON logging to all server-side routes and lib

Introduces a logger.ts module emitting slog-compatible JSON lines to stderr.
Replaces silent catch blocks and console.error calls throughout minio.ts,
pocketbase.ts, hooks.server.ts, login, books, browse, and all API routes so
auth/registration failures, MinIO presign errors, and scraper proxy failures
are now visible in container logs.
This commit is contained in:
Admin
2026-03-03 14:34:48 +05:00
parent 5131ae0bc4
commit bf5774d8d0
13 changed files with 188 additions and 37 deletions

View File

@@ -1,6 +1,7 @@
import { error } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import { env } from '$env/dynamic/private';
import { log } from '$lib/server/logger';
const SCRAPER_URL = env.SCRAPER_API_URL ?? 'http://localhost:8080';
@@ -27,11 +28,13 @@ export const load: PageServerLoad = async ({ url, locals }) => {
try {
const res = await fetch(apiURL);
if (!res.ok) {
log.error('browse', 'scraper browse returned error', { status: res.status, url: apiURL });
throw error(502, `Browse fetch failed: ${res.status}`);
}
data = await res.json();
} catch (e) {
if (e instanceof Error && 'status' in e) throw e;
log.error('browse', 'scraper browse network error', { url: apiURL, err: String(e) });
throw error(502, 'Could not load browse page');
}