feat(server): migrate all logging to pino
- Add pino with pino-pretty for structured logging
- Create root logger in index.ts with child loggers per module
- Support log level via PASEO_LOG env var and config.json
- Support log format (pretty/json) via PASEO_LOG_FORMAT and config.json
- Replace all console.* in runtime code with appropriate log levels
- Scripts use process.stdout/stderr for output
- Error logging uses correct pattern: logger.error({ err }, msg)
This commit is contained in:
@@ -29,12 +29,12 @@ function spawnServer() {
|
||||
// Restart on: explicit restart request, or any non-zero exit (crash)
|
||||
if (restarting || (code !== 0 && code !== null)) {
|
||||
restarting = false;
|
||||
console.warn(`[DevRunner] Server exited (${exitDescriptor}). Restarting...`);
|
||||
process.stderr.write(`[DevRunner] Server exited (${exitDescriptor}). Restarting...\n`);
|
||||
spawnServer();
|
||||
return;
|
||||
}
|
||||
|
||||
console.warn(`[DevRunner] Server exited (${exitDescriptor}). Shutting down.`);
|
||||
process.stderr.write(`[DevRunner] Server exited (${exitDescriptor}). Shutting down.\n`);
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
@@ -45,7 +45,7 @@ function restartServer() {
|
||||
}
|
||||
|
||||
restarting = true;
|
||||
console.warn("[DevRunner] Restart requested. Stopping current server...");
|
||||
process.stderr.write("[DevRunner] Restart requested. Stopping current server...\n");
|
||||
child.kill("SIGTERM");
|
||||
}
|
||||
|
||||
@@ -59,5 +59,5 @@ function forwardSignal(signal: NodeJS.Signals) {
|
||||
process.on("SIGINT", () => forwardSignal("SIGINT"));
|
||||
process.on("SIGTERM", () => forwardSignal("SIGTERM"));
|
||||
|
||||
console.log("[DevRunner] Starting server with tsx (explicit restarts only)");
|
||||
process.stdout.write("[DevRunner] Starting server with tsx (explicit restarts only)\n");
|
||||
spawnServer();
|
||||
|
||||
@@ -7,24 +7,24 @@ async function processConversation() {
|
||||
const conversationPath =
|
||||
".debug.conversations/ce44c79a-0689-4210-8e00-72c0a627406d-2.json";
|
||||
|
||||
console.log("Loading conversation from:", conversationPath);
|
||||
process.stdout.write(`Loading conversation from: ${conversationPath}\n`);
|
||||
|
||||
const conversationData: any = JSON.parse(
|
||||
readFileSync(conversationPath, "utf-8")
|
||||
);
|
||||
|
||||
console.log(
|
||||
`\nLoaded conversation ${conversationData.conversationId} with ${conversationData.messages.length} messages\n`
|
||||
process.stdout.write(
|
||||
`\nLoaded conversation ${conversationData.conversationId} with ${conversationData.messages.length} messages\n\n`
|
||||
);
|
||||
|
||||
const result = await standardizePrompt({
|
||||
prompt: conversationData.messages,
|
||||
});
|
||||
|
||||
console.log("Standardized prompt result:");
|
||||
console.log(inspect(result, { depth: null, colors: true }));
|
||||
process.stdout.write("Standardized prompt result:\n");
|
||||
process.stdout.write(inspect(result, { depth: null, colors: true }) + "\n");
|
||||
} catch (error) {
|
||||
console.error("Error processing conversation:", error);
|
||||
process.stderr.write(`Error processing conversation: ${error}\n`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ async function main() {
|
||||
(data) => {
|
||||
const event = (data.params as { msg: unknown }).msg as { type?: string };
|
||||
if (event.type === "mcp_startup_update" || event.type === "mcp_startup_complete") {
|
||||
console.log("MCP Event:", JSON.stringify(event, null, 2));
|
||||
process.stdout.write("MCP Event: " + JSON.stringify(event, null, 2) + "\n");
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -38,7 +38,7 @@ async function main() {
|
||||
await client.connect(transport);
|
||||
|
||||
// Use correct route (/mcp/agents) and bearer token env var
|
||||
console.log("\n=== Testing HTTP MCP server with correct route and bearer token ===\n");
|
||||
process.stdout.write("\n=== Testing HTTP MCP server with correct route and bearer token ===\n\n");
|
||||
|
||||
try {
|
||||
const result = await client.callTool({
|
||||
@@ -58,18 +58,21 @@ async function main() {
|
||||
}
|
||||
}, undefined, { timeout: 60000 });
|
||||
|
||||
console.log("\n=== RESULT ===");
|
||||
process.stdout.write("\n=== RESULT ===\n");
|
||||
const content = (result as { content: { text?: string }[] }).content;
|
||||
for (const item of content) {
|
||||
if (item.text) {
|
||||
console.log(item.text);
|
||||
process.stdout.write(item.text + "\n");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
process.stderr.write("Error: " + String(error) + "\n");
|
||||
}
|
||||
|
||||
await client.close();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
main().catch((error) => {
|
||||
process.stderr.write(String(error) + "\n");
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ async function main() {
|
||||
(data) => {
|
||||
const event = (data.params as { msg: unknown }).msg as { type?: string };
|
||||
if (event.type === "mcp_startup_update" || event.type === "mcp_startup_complete") {
|
||||
console.log("MCP Event:", JSON.stringify(event, null, 2));
|
||||
process.stdout.write("MCP Event: " + JSON.stringify(event, null, 2) + "\n");
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -35,7 +35,7 @@ async function main() {
|
||||
await client.connect(transport);
|
||||
|
||||
// Try passing MCP server config via the config parameter with headers
|
||||
console.log("\n=== Testing HTTP MCP server with basic auth in config ===\n");
|
||||
process.stdout.write("\n=== Testing HTTP MCP server with basic auth in config ===\n\n");
|
||||
|
||||
try {
|
||||
// Create base64 encoded credentials
|
||||
@@ -61,18 +61,21 @@ async function main() {
|
||||
}
|
||||
}, undefined, { timeout: 60000 });
|
||||
|
||||
console.log("\n=== RESULT ===");
|
||||
process.stdout.write("\n=== RESULT ===\n");
|
||||
const content = (result as { content: { text?: string }[] }).content;
|
||||
for (const item of content) {
|
||||
if (item.text) {
|
||||
console.log(item.text);
|
||||
process.stdout.write(item.text + "\n");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
process.stderr.write("Error: " + String(error) + "\n");
|
||||
}
|
||||
|
||||
await client.close();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
main().catch((error) => {
|
||||
process.stderr.write(String(error) + "\n");
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ async function main() {
|
||||
(data) => {
|
||||
const event = (data.params as { msg: unknown }).msg as { type?: string };
|
||||
if (event.type === "mcp_startup_update" || event.type === "mcp_startup_complete") {
|
||||
console.log("MCP Event:", JSON.stringify(event, null, 2));
|
||||
process.stdout.write("MCP Event: " + JSON.stringify(event, null, 2) + "\n");
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -38,7 +38,7 @@ async function main() {
|
||||
await client.connect(transport);
|
||||
|
||||
// Try passing MCP server config with bearer_token_env_var
|
||||
console.log("\n=== Testing HTTP MCP server with bearer_token_env_var ===\n");
|
||||
process.stdout.write("\n=== Testing HTTP MCP server with bearer_token_env_var ===\n\n");
|
||||
|
||||
try {
|
||||
const result = await client.callTool({
|
||||
@@ -58,18 +58,21 @@ async function main() {
|
||||
}
|
||||
}, undefined, { timeout: 60000 });
|
||||
|
||||
console.log("\n=== RESULT ===");
|
||||
process.stdout.write("\n=== RESULT ===\n");
|
||||
const content = (result as { content: { text?: string }[] }).content;
|
||||
for (const item of content) {
|
||||
if (item.text) {
|
||||
console.log(item.text);
|
||||
process.stdout.write(item.text + "\n");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
process.stderr.write("Error: " + String(error) + "\n");
|
||||
}
|
||||
|
||||
await client.close();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
main().catch((error) => {
|
||||
process.stderr.write(String(error) + "\n");
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ async function main() {
|
||||
(data) => {
|
||||
const event = (data.params as { msg: unknown }).msg as { type?: string };
|
||||
if (event.type === "mcp_startup_update" || event.type === "mcp_startup_complete") {
|
||||
console.log("MCP Event:", JSON.stringify(event, null, 2));
|
||||
process.stdout.write("MCP Event: " + JSON.stringify(event, null, 2) + "\n");
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -36,7 +36,7 @@ async function main() {
|
||||
await client.connect(transport);
|
||||
|
||||
// Test using http_headers with Authorization
|
||||
console.log("\n=== Testing HTTP MCP server with http_headers and Authorization ===\n");
|
||||
process.stdout.write("\n=== Testing HTTP MCP server with http_headers and Authorization ===\n\n");
|
||||
|
||||
try {
|
||||
const result = await client.callTool({
|
||||
@@ -58,18 +58,21 @@ async function main() {
|
||||
}
|
||||
}, undefined, { timeout: 60000 });
|
||||
|
||||
console.log("\n=== RESULT ===");
|
||||
process.stdout.write("\n=== RESULT ===\n");
|
||||
const content = (result as { content: { text?: string }[] }).content;
|
||||
for (const item of content) {
|
||||
if (item.text) {
|
||||
console.log(item.text);
|
||||
process.stdout.write(item.text + "\n");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
process.stderr.write("Error: " + String(error) + "\n");
|
||||
}
|
||||
|
||||
await client.close();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
main().catch((error) => {
|
||||
process.stderr.write(String(error) + "\n");
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ async function main() {
|
||||
(data) => {
|
||||
const event = (data.params as { msg: unknown }).msg as { type?: string };
|
||||
if (event.type === "mcp_startup_update" || event.type === "mcp_startup_complete") {
|
||||
console.log("MCP Event:", JSON.stringify(event, null, 2));
|
||||
process.stdout.write("MCP Event: " + JSON.stringify(event, null, 2) + "\n");
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -31,7 +31,7 @@ async function main() {
|
||||
await client.connect(transport);
|
||||
|
||||
// Try passing MCP server config via the config parameter with HTTP URL
|
||||
console.log("\n=== Testing HTTP MCP server config (agent-control style) ===\n");
|
||||
process.stdout.write("\n=== Testing HTTP MCP server config (agent-control style) ===\n\n");
|
||||
|
||||
try {
|
||||
const result = await client.callTool({
|
||||
@@ -51,18 +51,21 @@ async function main() {
|
||||
}
|
||||
}, undefined, { timeout: 60000 });
|
||||
|
||||
console.log("\n=== RESULT ===");
|
||||
process.stdout.write("\n=== RESULT ===\n");
|
||||
const content = (result as { content: { text?: string }[] }).content;
|
||||
for (const item of content) {
|
||||
if (item.text) {
|
||||
console.log(item.text);
|
||||
process.stdout.write(item.text + "\n");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
process.stderr.write("Error: " + String(error) + "\n");
|
||||
}
|
||||
|
||||
await client.close();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
main().catch((error) => {
|
||||
process.stderr.write(String(error) + "\n");
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
@@ -28,18 +28,18 @@ async function main() {
|
||||
item?: { type?: string };
|
||||
};
|
||||
if (event.type === "turn.started") {
|
||||
console.log("\n=== TURN STARTED ===");
|
||||
process.stdout.write("\n=== TURN STARTED ===\n");
|
||||
} else if (event.type === "agent_message") {
|
||||
console.log("Agent:", event.data?.text || event.text);
|
||||
process.stdout.write("Agent: " + (event.data?.text || event.text) + "\n");
|
||||
} else if (event.type === "mcp_tool_call") {
|
||||
console.log("MCP Tool Call:", JSON.stringify(event.data));
|
||||
process.stdout.write("MCP Tool Call: " + JSON.stringify(event.data) + "\n");
|
||||
} else if (event.type === "thread.item") {
|
||||
const item = event.data?.item || event.item;
|
||||
if (item?.type === "mcp_tool_call") {
|
||||
console.log("MCP Tool from thread:", JSON.stringify(item));
|
||||
process.stdout.write("MCP Tool from thread: " + JSON.stringify(item) + "\n");
|
||||
}
|
||||
} else {
|
||||
console.log("Event:", event.type);
|
||||
process.stdout.write("Event: " + event.type + "\n");
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -47,7 +47,7 @@ async function main() {
|
||||
await client.connect(transport);
|
||||
|
||||
// Try passing MCP server config via the config parameter
|
||||
console.log("\n=== Testing dynamic MCP server config ===\n");
|
||||
process.stdout.write("\n=== Testing dynamic MCP server config ===\n\n");
|
||||
|
||||
try {
|
||||
const result = await client.callTool({
|
||||
@@ -67,18 +67,21 @@ async function main() {
|
||||
}
|
||||
}, undefined, { timeout: 60000 });
|
||||
|
||||
console.log("\n=== RESULT ===");
|
||||
process.stdout.write("\n=== RESULT ===\n");
|
||||
const content = (result as { content: { text?: string }[] }).content;
|
||||
for (const item of content) {
|
||||
if (item.text) {
|
||||
console.log(item.text);
|
||||
process.stdout.write(item.text + "\n");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
process.stderr.write("Error: " + String(error) + "\n");
|
||||
}
|
||||
|
||||
await client.close();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
main().catch((error) => {
|
||||
process.stderr.write(String(error) + "\n");
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
@@ -4,8 +4,8 @@ import { buildPaseoDaemonConfigFromEnv } from "../src/server/config.js";
|
||||
|
||||
const config = buildPaseoDaemonConfigFromEnv();
|
||||
|
||||
console.log("=== agentControlMcp config ===");
|
||||
console.log(JSON.stringify(config.agentControlMcp, null, 2));
|
||||
process.stdout.write("=== agentControlMcp config ===\n");
|
||||
process.stdout.write(JSON.stringify(config.agentControlMcp, null, 2) + "\n");
|
||||
|
||||
// Simulate what buildCodexMcpConfig does
|
||||
const mcpServers: Record<string, unknown> = {};
|
||||
@@ -23,5 +23,5 @@ mcpServers["playwright"] = {
|
||||
args: ["@playwright/mcp", "--headless", "--isolated"],
|
||||
};
|
||||
|
||||
console.log("\n=== Built MCP servers config ===");
|
||||
console.log(JSON.stringify(mcpServers, null, 2));
|
||||
process.stdout.write("\n=== Built MCP servers config ===\n");
|
||||
process.stdout.write(JSON.stringify(mcpServers, null, 2) + "\n");
|
||||
|
||||
Reference in New Issue
Block a user