Skip to content

Commit 3d804b0

Browse files
committed
Logging tweaks
1 parent 5e4349a commit 3d804b0

File tree

4 files changed

+47
-75
lines changed

4 files changed

+47
-75
lines changed

benchmark/apps/cli/src/index.ts

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -222,30 +222,23 @@ const runExercise = async ({ run, task, server }: { run: Run; task: Task; server
222222
})
223223

224224
client.sendMessage({
225-
type: IpcMessageType.VSCodeCommand,
225+
type: IpcMessageType.TaskCommand,
226226
origin: IpcOrigin.Client,
227227
clientId: client.clientId!,
228-
data: "workbench.action.closeWindow",
228+
data: {
229+
commandName: TaskCommandName.StartNewTask,
230+
data: {
231+
configuration: {
232+
...rooCodeDefaults,
233+
openRouterApiKey: process.env.OPENROUTER_API_KEY!,
234+
...run.settings,
235+
},
236+
text: prompt,
237+
newTab: true,
238+
},
239+
},
229240
})
230241

231-
// client.sendMessage({
232-
// type: IpcMessageType.TaskCommand,
233-
// origin: IpcOrigin.Client,
234-
// clientId: client.clientId!,
235-
// data: {
236-
// commandName: TaskCommandName.StartNewTask,
237-
// data: {
238-
// configuration: {
239-
// ...rooCodeDefaults,
240-
// openRouterApiKey: process.env.OPENROUTER_API_KEY!,
241-
// ...run.settings,
242-
// },
243-
// text: prompt,
244-
// newTab: true,
245-
// },
246-
// },
247-
// })
248-
249242
console.log(`[cli#runExercise | ${language} / ${exercise}] StartNewTask`)
250243

251244
try {

src/exports/api.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { openClineInNewTab } from "../activate/registerCommands"
66

77
import { RooCodeSettings, RooCodeEvents, RooCodeEventName } from "../schemas"
88
import { IpcOrigin, IpcMessageType, TaskCommandName, TaskEvent } from "../schemas/ipc"
9-
import { formatLog } from "./formatLog"
109
import { RooCodeAPI } from "./interface"
1110
import { IpcServer } from "./ipc"
11+
import { outputChannelLog } from "./log"
1212

1313
export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
1414
private readonly outputChannel: vscode.OutputChannel
@@ -27,8 +27,7 @@ export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
2727
this.registerListeners(this.sidebarProvider)
2828

2929
if (socketPath) {
30-
this.ipc = new IpcServer(socketPath, (...args: unknown[]) => formatLog(this.outputChannel, ...args))
31-
30+
this.ipc = new IpcServer(socketPath, (...args: unknown[]) => outputChannelLog(this.outputChannel, ...args))
3231
this.ipc.listen()
3332

3433
this.outputChannel.appendLine(

src/exports/formatLog.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/exports/log.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as vscode from "vscode"
2+
3+
export function outputChannelLog(outputChannel: vscode.OutputChannel, ...args: unknown[]) {
4+
for (const arg of args) {
5+
if (arg === null) {
6+
outputChannel.appendLine("null")
7+
} else if (arg === undefined) {
8+
outputChannel.appendLine("undefined")
9+
} else if (typeof arg === "string") {
10+
outputChannel.appendLine(arg)
11+
} else if (arg instanceof Error) {
12+
outputChannel.appendLine(`Error: ${arg.message}\n${arg.stack || ""}`)
13+
} else {
14+
try {
15+
outputChannel.appendLine(
16+
JSON.stringify(
17+
arg,
18+
(key, value) => {
19+
if (typeof value === "bigint") return `BigInt(${value})`
20+
if (typeof value === "function") return `Function: ${value.name || "anonymous"}`
21+
if (typeof value === "symbol") return value.toString()
22+
return value
23+
},
24+
2,
25+
),
26+
)
27+
} catch (error) {
28+
outputChannel.appendLine(`[Non-serializable object: ${Object.prototype.toString.call(arg)}]`)
29+
}
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)