Add structured backend logging with pino
Wires leveled, structured logging (pretty in dev, JSON in prod) through the server lifecycle, HTTP/WS request handling, run engine, auth, db, and config loading. CLI command output is left untouched since it's user-facing terminal UX, not backend logs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,9 @@ import { requireAuth, unauthorizedResponse } from "@/lib/auth/guard";
|
||||
import { getDb } from "@/lib/db/client";
|
||||
import { runs } from "@/lib/db/schema";
|
||||
import { cancelRun } from "@/lib/runner/registry";
|
||||
import { logger } from "@/lib/logger";
|
||||
|
||||
const log = logger.child({ mod: "api" });
|
||||
|
||||
export async function POST(
|
||||
request: Request,
|
||||
@@ -27,11 +30,16 @@ export async function POST(
|
||||
|
||||
const cancelled = cancelRun(runId);
|
||||
if (!cancelled) {
|
||||
log.warn(
|
||||
{ runId },
|
||||
"cancel requested for a run not tracked by this process",
|
||||
);
|
||||
return Response.json(
|
||||
{ error: "Run is not active in this server process" },
|
||||
{ status: 409 },
|
||||
);
|
||||
}
|
||||
|
||||
log.info({ runId, requestedBy: auth.identity }, "cancel requested via API");
|
||||
return Response.json({ status: "cancelling" }, { status: 202 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user