Add comprehensive local logging to all microservices; log all errors locally and forward to error_log_api
This commit is contained in:
@@ -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" });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user