mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat: add LOG_LEVEL env var and improve error messages
Add configurable LOG_LEVEL (fatal/error/warn/info/debug/trace) for Fastify logger. Always return error details in tool processing responses and combine error + details in frontend display.
This commit is contained in:
@@ -34,7 +34,7 @@ await ensureDefaultAdmin();
|
|||||||
recoverStaleJobs();
|
recoverStaleJobs();
|
||||||
|
|
||||||
const app = Fastify({
|
const app = Fastify({
|
||||||
logger: true,
|
logger: { level: env.LOG_LEVEL },
|
||||||
bodyLimit: env.MAX_UPLOAD_SIZE_MB * 1024 * 1024,
|
bodyLimit: env.MAX_UPLOAD_SIZE_MB * 1024 * 1024,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const envSchema = z.object({
|
|||||||
APP_NAME: z.string().default("Stirling Image"),
|
APP_NAME: z.string().default("Stirling Image"),
|
||||||
CORS_ORIGIN: z.string().default(""),
|
CORS_ORIGIN: z.string().default(""),
|
||||||
MAX_USERS: z.coerce.number().default(5),
|
MAX_USERS: z.coerce.number().default(5),
|
||||||
|
LOG_LEVEL: z.enum(["fatal", "error", "warn", "info", "debug", "trace"]).default("info"),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type Env = z.infer<typeof envSchema>;
|
export type Env = z.infer<typeof envSchema>;
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ export function createToolRoute<T>(app: FastifyInstance, config: ToolRouteConfig
|
|||||||
request.log.error({ err, toolId: config.toolId }, "Tool processing failed");
|
request.log.error({ err, toolId: config.toolId }, "Tool processing failed");
|
||||||
return reply.status(422).send({
|
return reply.status(422).send({
|
||||||
error: "Processing failed",
|
error: "Processing failed",
|
||||||
details: process.env.NODE_ENV === "production" ? undefined : message,
|
details: message,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -186,7 +186,10 @@ export function useToolProcessor(toolId: string) {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const body = JSON.parse(xhr.responseText);
|
const body = JSON.parse(xhr.responseText);
|
||||||
setError(body.error || body.details || `Processing failed: ${xhr.status}`);
|
const msg = body.details
|
||||||
|
? `${body.error}: ${body.details}`
|
||||||
|
: body.error || `Processing failed: ${xhr.status}`;
|
||||||
|
setError(msg);
|
||||||
} catch {
|
} catch {
|
||||||
setError(`Processing failed: ${xhr.status}`);
|
setError(`Processing failed: ${xhr.status}`);
|
||||||
}
|
}
|
||||||
@@ -305,7 +308,9 @@ export function useToolProcessor(toolId: string) {
|
|||||||
let errorMsg: string;
|
let errorMsg: string;
|
||||||
try {
|
try {
|
||||||
const body = JSON.parse(text);
|
const body = JSON.parse(text);
|
||||||
errorMsg = body.error || body.details || `Batch processing failed: ${response.status}`;
|
errorMsg = body.details
|
||||||
|
? `${body.error}: ${body.details}`
|
||||||
|
: body.error || `Batch processing failed: ${response.status}`;
|
||||||
} catch {
|
} catch {
|
||||||
errorMsg = `Batch processing failed: ${response.status}`;
|
errorMsg = `Batch processing failed: ${response.status}`;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -182,7 +182,8 @@ ENV PORT=1349 \
|
|||||||
MAX_BATCH_SIZE=200 \
|
MAX_BATCH_SIZE=200 \
|
||||||
CONCURRENT_JOBS=3 \
|
CONCURRENT_JOBS=3 \
|
||||||
MAX_MEGAPIXELS=100 \
|
MAX_MEGAPIXELS=100 \
|
||||||
RATE_LIMIT_PER_MIN=100
|
RATE_LIMIT_PER_MIN=100 \
|
||||||
|
LOG_LEVEL=info
|
||||||
|
|
||||||
# NVIDIA Container Toolkit env vars (harmless on non-GPU systems)
|
# NVIDIA Container Toolkit env vars (harmless on non-GPU systems)
|
||||||
ENV NVIDIA_VISIBLE_DEVICES=all \
|
ENV NVIDIA_VISIBLE_DEVICES=all \
|
||||||
|
|||||||
Reference in New Issue
Block a user