debug logs from sdk are now shown in routstrd logs

This commit is contained in:
redshift
2026-03-23 13:24:19 +00:00
parent d4c578c246
commit 44e439631e
2 changed files with 18 additions and 11 deletions
-1
View File
@@ -445,7 +445,6 @@ export function createDaemonRequestHandler(deps: {
res.on("finish", () => {
if (capturedUsage) {
const usageRequestId = capturedResponseId || requestId || "unknown";
logger.log(req);
usageTracker.append({
id:
usageRequestId === "unknown"
+18 -10
View File
@@ -1,5 +1,7 @@
import { LOG_FILE } from "./utils/config";
import { logger } from "./utils/logger";
import { existsSync, mkdirSync } from "fs";
import { dirname, join } from "path";
export async function startDaemon(
options: { port?: string; provider?: string } = {},
@@ -31,17 +33,23 @@ export async function startDaemon(
args.push("--provider", options.provider);
}
const logFile = Bun.file(LOG_FILE);
// Ensure log directory exists
const logDir = dirname(LOG_FILE);
if (!existsSync(logDir)) {
mkdirSync(logDir, { recursive: true });
}
const proc = Bun.spawn(
["bun", "run", `${import.meta.dir}/daemon/index.ts`, ...args],
{
stdout: logFile,
stderr: logFile,
stdin: "ignore",
detached: true,
},
);
// Use shell redirection to append stdout/stderr to log file
// Bun.file() overwrites, so we need shell >> for appending
const daemonScript = `${import.meta.dir}/daemon/index.ts`;
const shellCmd = `bun run "${daemonScript}" ${args.map(a => `'${a}'`).join(" ")} >> "${LOG_FILE}" 2>&1`;
const proc = Bun.spawn(["sh", "-c", shellCmd], {
stdout: "inherit",
stderr: "inherit",
stdin: "ignore",
detached: true,
});
proc.unref();