Add comprehensive local logging to all microservices; log all errors locally and forward to error_log_api

This commit is contained in:
Sven laptop
2026-09-23 20:00:30 +02:00
parent 50634a3ed7
commit b36975b680
4 changed files with 54 additions and 28 deletions
+3 -1
View File
@@ -54,6 +54,7 @@ app.use((req, res, next) => {
if (res.statusCode >= 400 && body && typeof body === "object") {
const rawError =
body.error || body.message || body.details || `HTTP ${res.statusCode}`;
log("warn", `HTTP ${res.statusCode}`, { path: req.originalUrl, method: req.method, error: rawError });
void reportError({
partofservice: `${req.method} ${req.originalUrl}`,
error: rawError,
@@ -71,7 +72,8 @@ app.get("/health", async (_req, res) => {
await db.query("SELECT 1");
res.json({ status: "ok", service: "transit_api", database: "ok" });
} catch (err) {
console.error("GET /health error:", err);
log("error", "GET /health error", { error: err.message, stack: err.stack });
reportError({ partofservice: "GET /health", error: err.stack || err.message });
res.status(503).json({ status: "unavailable", service: "transit_api" });
}
});