mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
fix(api): tighten logging env + improve error/request body logging
This commit is contained in:
parent
13674b28fd
commit
8b43a8448f
3 changed files with 7 additions and 11 deletions
|
|
@ -89,20 +89,18 @@ function getEnvLocalValues(): Record<string, string> {
|
|||
* Check if API logging is enabled
|
||||
*
|
||||
* Checks in order:
|
||||
* 1. Workspace .env.local: ROO_CODE_API_LOGGING=true or ROO_CODE_LOGGING=true (for user's workspace)
|
||||
* 1. Workspace .env.local: ROO_CODE_API_LOGGING=true (for user's workspace)
|
||||
* 2. Process env (loaded from extension's .env.local via envFile in launch.json)
|
||||
*
|
||||
* Note: Both ROO_CODE_API_LOGGING and ROO_CODE_LOGGING are accepted for backward compatibility
|
||||
*/
|
||||
export function isLoggingEnabled(): boolean {
|
||||
// Check workspace .env.local first (user's current workspace)
|
||||
const envLocal = getEnvLocalValues()
|
||||
if (envLocal["ROO_CODE_API_LOGGING"] === "true" || envLocal["ROO_CODE_LOGGING"] === "true") {
|
||||
if (envLocal["ROO_CODE_API_LOGGING"] === "true") {
|
||||
return true
|
||||
}
|
||||
|
||||
// Fallback to process.env (populated from extension's .env.local via launch.json envFile)
|
||||
return process.env.ROO_CODE_API_LOGGING === "true" || process.env.ROO_CODE_LOGGING === "true"
|
||||
return process.env.ROO_CODE_API_LOGGING === "true"
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ export function createLoggingFetch(providerName: string): typeof fetch {
|
|||
method,
|
||||
url,
|
||||
headers: sanitizeHeaders(headers),
|
||||
body: init?.body ? parseBodyIfJson(init.body) : undefined,
|
||||
body: init?.body === undefined || init.body === null ? undefined : parseBodyIfJson(init.body),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -407,11 +407,9 @@ export class ClaudeCodeHandler implements ApiHandler, SingleCompletionHandler {
|
|||
|
||||
return result
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error && error.message)) {
|
||||
ApiLogger.logError(requestId, context, {
|
||||
message: error instanceof Error ? error.message : String(error),
|
||||
})
|
||||
}
|
||||
ApiLogger.logError(requestId, context, {
|
||||
message: error instanceof Error ? error.message : String(error),
|
||||
})
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue