Add structured runtime logging

This commit is contained in:
morluto
2026-07-12 10:57:34 +08:00
parent 5ed56d63e0
commit 03072e0ea7
16 changed files with 795 additions and 48 deletions
+8
View File
@@ -13,6 +13,7 @@ describe("runtime configuration", () => {
expect(result.value.hopperLauncherPath).toContain("/MacOS/hopper");
expect(result.value.hopperTargetKind).toBe("executable");
expect(result.value.hopperLoaderArgs).toEqual([]);
expect(result.value.logLevel).toBe("info");
}
});
@@ -31,6 +32,7 @@ describe("runtime configuration", () => {
hopperTargetPath: "/fixture/sample.hop",
hopperTargetKind: "database",
hopperLoaderArgs: ["-l", "FAT", "--aarch64", "-l", "Mach-O"],
logLevel: "info",
},
});
});
@@ -46,4 +48,10 @@ describe("runtime configuration", () => {
).toBe(false);
},
);
it("parses supported log levels and rejects unknown levels", () => {
const configured = parseConfig({ REA_LOG_LEVEL: "debug" });
expect(configured.ok && configured.value.logLevel).toBe("debug");
expect(parseConfig({ REA_LOG_LEVEL: "verbose" }).ok).toBe(false);
});
});
+16 -1
View File
@@ -42,7 +42,22 @@ describe("production stdio runtime", () => {
await client.close();
await transport.close();
}
expect(stderr).toBe("");
const records = stderr
.trim()
.split("\n")
.filter((line) => line.length > 0)
.map((line: string): unknown => JSON.parse(line));
expect(records).toContainEqual(
expect.objectContaining({
application: "rea",
mode: "mcp",
layer: "server",
tool: "current_document",
status: "ok",
}),
);
expect(stderr).not.toContain("HOPPER_LOADER_ARGS_JSON");
expect(stderr).not.toContain(fixturePath);
});
it("honors the configured kind for an initial database target", async () => {