Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Sep 17, 2025

This PR implements the enhanced logging feature requested in Issue #8098.

Summary

Adds a global "Enhanced logging" toggle to the Settings → Info (About) section that enables detailed failure logs to be written to the VS Code Output panel for troubleshooting purposes.

Changes

  • ✅ Added enhancedLoggingEnabled toggle in Settings → Info (About) section
  • ✅ Created logEnhancedError and logEnhanced utility functions for detailed logging
  • ✅ Implemented automatic sanitization of sensitive data (API keys, tokens, passwords)
  • ✅ Integrated enhanced logging into API error handling in the Task class
  • ✅ Added yellow warning banner that displays when enhanced logging is enabled
  • ✅ Added comprehensive test coverage for all logging functionality
  • ✅ Logs are written to VS Code Output panel (local only, no auto-upload)

Security Considerations

  • All sensitive information is automatically sanitized before logging
  • API keys, tokens, and passwords are redacted showing only first/last 4 characters
  • Logs remain local only - no automatic upload or sharing
  • Feature is disabled by default

Testing

  • All tests pass (3823 passed)
  • Added comprehensive test suite for enhanced logging functionality
  • Linting and type checking pass

Screenshots

When enabled, users will see:

  1. A checkbox in Settings → Info (About) section
  2. A yellow warning banner at the top of the chat view
  3. Detailed error logs in the VS Code Output panel when errors occur

Fixes #8098


Important

This PR adds an enhanced logging feature for detailed error logging and troubleshooting, with UI integration and comprehensive test coverage.

  • Behavior:
    • Adds enhancedLoggingEnabled toggle in global-settings.ts and webviewMessageHandler.ts.
    • Introduces logEnhancedError and logEnhanced functions in enhancedLogging.ts for detailed logging.
    • Logs are written to the VS Code Output panel, with sensitive data sanitized.
    • Enhanced logging integrated into Task.ts for API error handling.
    • Displays a yellow warning banner in ChatView.tsx when enhanced logging is enabled.
  • UI Components:
    • Adds EnhancedLoggingBanner component in EnhancedLoggingBanner.tsx.
    • Updates About.tsx to include enhanced logging toggle.
  • Context and State:
    • Updates ExtensionStateContext.tsx to manage enhanced logging state.
  • Testing:
    • Adds tests in enhancedLogging.spec.ts to cover logging functionality.
  • Localization:
    • Updates settings.json for enhanced logging descriptions and labels.

This description was created by Ellipsis for 27558b8. You can customize this summary. It will automatically update as commits are pushed.

- Add enhancedLoggingEnabled toggle in Settings → Info (About) section
- Create logEnhancedError and logEnhanced utility functions
- Add sanitization for sensitive data in logs
- Integrate enhanced logging into API error handling
- Add yellow warning banner when enhanced logging is enabled
- Add comprehensive test coverage for logging functionality
- Export disposeEnhancedLogging for proper cleanup

Implements #8098
@roomote roomote bot requested review from cte, jr and mrubens as code owners September 17, 2025 23:48
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Sep 17, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 18, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed my own code and found it surprisingly coherent. Must be a bug in the review process.

if (error.stack) {
channel.appendLine("")
channel.appendLine("Stack Trace:")
channel.appendLine(error.stack)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding rate limiting here to prevent log flooding. If errors occur in a tight loop, this could generate massive amounts of log data. Maybe implement a simple throttle mechanism or circular buffer?

channel.appendLine(`Provider: ${additionalContext.provider}`)
}

if (additionalContext?.model) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice security implementation with the sanitization! Consider adding JSDoc comments to document the log output format. This would help developers understand what to expect when reading the logs:

provider?: string
model?: string
request?: any
response?: any
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sanitization pattern is good, but have you considered making the redaction length configurable? Some users might prefer seeing more or fewer characters for debugging purposes.

})
}

if (!enhancedLoggingEnabled) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a "Copy Recent Logs" button here alongside the close button. This would make it easier for users to quickly grab logs for bug reports without navigating to the Output panel.

const provider = this.providerRef.deref()
if (provider && !this.abort) {
logEnhancedError(provider.context, error, {
operation: "API Stream Processing",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good integration point! Consider adding log levels (ERROR, WARN, INFO) in the future for more granular control. Users might want to log only critical errors vs all API interactions.

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Sep 22, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 22, 2025
@daniel-lxs daniel-lxs closed this Sep 22, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 22, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Needs Preliminary Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Global enhanced logging to VS Code Output + warning banner

4 participants