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:
Siddharth Kumar Sah
2026-04-11 14:47:30 +08:00
parent f2696443dc
commit 6c1a347f1c
5 changed files with 12 additions and 5 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ await ensureDefaultAdmin();
recoverStaleJobs();
const app = Fastify({
logger: true,
logger: { level: env.LOG_LEVEL },
bodyLimit: env.MAX_UPLOAD_SIZE_MB * 1024 * 1024,
});
+1
View File
@@ -28,6 +28,7 @@ const envSchema = z.object({
APP_NAME: z.string().default("Stirling Image"),
CORS_ORIGIN: z.string().default(""),
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>;
+1 -1
View File
@@ -306,7 +306,7 @@ export function createToolRoute<T>(app: FastifyInstance, config: ToolRouteConfig
request.log.error({ err, toolId: config.toolId }, "Tool processing failed");
return reply.status(422).send({
error: "Processing failed",
details: process.env.NODE_ENV === "production" ? undefined : message,
details: message,
});
}
},