fix: fetch url logs
Browse files- Dockerfile +1 -1
- src/lib/server/logger.ts +9 -1
- src/routes/api/fetch-url/+server.ts +5 -1
Dockerfile
CHANGED
|
@@ -21,7 +21,7 @@ RUN touch /app/.env.local
|
|
| 21 |
|
| 22 |
USER root
|
| 23 |
RUN apt-get update
|
| 24 |
-
RUN apt-get install -y libgomp1 libcurl4
|
| 25 |
|
| 26 |
# ensure npm cache dir exists before adjusting ownership
|
| 27 |
RUN mkdir -p /home/user/.npm && chown -R 1000:1000 /home/user/.npm
|
|
|
|
| 21 |
|
| 22 |
USER root
|
| 23 |
RUN apt-get update
|
| 24 |
+
RUN apt-get install -y libgomp1 libcurl4 curl dnsutils
|
| 25 |
|
| 26 |
# ensure npm cache dir exists before adjusting ownership
|
| 27 |
RUN mkdir -p /home/user/.npm && chown -R 1000:1000 /home/user/.npm
|
src/lib/server/logger.ts
CHANGED
|
@@ -15,4 +15,12 @@ if (dev) {
|
|
| 15 |
};
|
| 16 |
}
|
| 17 |
|
| 18 |
-
export const logger = pino({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
};
|
| 16 |
}
|
| 17 |
|
| 18 |
+
export const logger = pino({
|
| 19 |
+
...options,
|
| 20 |
+
level: config.LOG_LEVEL || "info",
|
| 21 |
+
formatters: {
|
| 22 |
+
level: (label) => {
|
| 23 |
+
return { level: label };
|
| 24 |
+
},
|
| 25 |
+
},
|
| 26 |
+
});
|
src/routes/api/fetch-url/+server.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import { error } from "@sveltejs/kit";
|
|
|
|
| 2 |
|
| 3 |
const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
|
| 4 |
const FETCH_TIMEOUT = 30000; // 30 seconds
|
|
@@ -87,11 +88,14 @@ export async function GET({ url, fetch }) {
|
|
| 87 |
} catch (err) {
|
| 88 |
if (err instanceof Error) {
|
| 89 |
if (err.name === "AbortError") {
|
|
|
|
| 90 |
throw error(504, "Request timeout");
|
| 91 |
}
|
| 92 |
-
|
|
|
|
| 93 |
throw error(500, `Failed to fetch URL: ${err.message}`);
|
| 94 |
}
|
|
|
|
| 95 |
throw error(500, "Failed to fetch URL");
|
| 96 |
}
|
| 97 |
}
|
|
|
|
| 1 |
import { error } from "@sveltejs/kit";
|
| 2 |
+
import { logger } from "$lib/server/logger.js";
|
| 3 |
|
| 4 |
const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
|
| 5 |
const FETCH_TIMEOUT = 30000; // 30 seconds
|
|
|
|
| 88 |
} catch (err) {
|
| 89 |
if (err instanceof Error) {
|
| 90 |
if (err.name === "AbortError") {
|
| 91 |
+
logger.error(err, `Request timeout`);
|
| 92 |
throw error(504, "Request timeout");
|
| 93 |
}
|
| 94 |
+
|
| 95 |
+
logger.error(err, `Error fetching URL`);
|
| 96 |
throw error(500, `Failed to fetch URL: ${err.message}`);
|
| 97 |
}
|
| 98 |
+
logger.error(err, `Error fetching URL`);
|
| 99 |
throw error(500, "Failed to fetch URL");
|
| 100 |
}
|
| 101 |
}
|