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:
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user