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 { json, error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { setProgress } from '$lib/server/pocketbase';
|
||||
import { log } from '$lib/server/logger';
|
||||
|
||||
/**
|
||||
* POST /api/progress
|
||||
@@ -14,6 +15,11 @@ export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
error(400, 'Invalid body — expected { slug, chapter }');
|
||||
}
|
||||
|
||||
await setProgress(locals.sessionId, body.slug, body.chapter);
|
||||
try {
|
||||
await setProgress(locals.sessionId, body.slug, body.chapter);
|
||||
} catch (e) {
|
||||
log.error('progress', 'setProgress failed', { slug: body.slug, chapter: body.chapter, err: String(e) });
|
||||
error(500, 'Failed to save progress');
|
||||
}
|
||||
return json({ ok: true });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user