Skip to content

Commit 90b4e5c

Browse files
authored
Easier to read Anthropic trace logging (#8407)
Tiny change to add indentation to the trace logs for Anthropic API calls. ### QA Notes 1. Run Positron command `Developer: Set Log Level...` and set to trace. 2. Interact with Positron Assistant 3. Run Positron command `Developer: Show Logs...` and choose Assistant Observe that JSON traffic is pretty-printed so it's much easier to read
1 parent 9a88864 commit 90b4e5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

extensions/positron-assistant/src/anthropic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class AnthropicLanguageModel implements positron.ai.LanguageModelChatProv
9898
// Log request information - the request ID is only available upon connection.
9999
stream.on('connect', () => {
100100
if (log.logLevel <= vscode.LogLevel.Trace) {
101-
log.trace(`[anthropic] SEND messages.stream [${stream.request_id}]: ${JSON.stringify(body)}`);
101+
log.trace(`[anthropic] SEND messages.stream [${stream.request_id}]: ${JSON.stringify(body, null, 2)}`);
102102
} else {
103103
const userMessages = body.messages.filter(m => m.role === 'user');
104104
const assistantMessages = body.messages.filter(m => m.role === 'assistant');
@@ -155,7 +155,7 @@ export class AnthropicLanguageModel implements positron.ai.LanguageModelChatProv
155155
// Log usage information.
156156
const message = await stream.finalMessage();
157157
if (log.logLevel <= vscode.LogLevel.Trace) {
158-
log.trace(`[anthropic] RECV messages.stream [${stream.request_id}]: ${JSON.stringify(message)}`);
158+
log.trace(`[anthropic] RECV messages.stream [${stream.request_id}]: ${JSON.stringify(message, null, 2)}`);
159159
} else {
160160
log.debug(
161161
`[anthropic] RECV messages.stream [${stream.request_id}]: ` +

0 commit comments

Comments
 (0)