Skip to content

feat(cli): add --debug flag to write all trace logs to ./debug.txt#296

Merged
echobt merged 1 commit intomasterfrom
feat/debug-mode-file-logging
Jan 27, 2026
Merged

feat(cli): add --debug flag to write all trace logs to ./debug.txt#296
echobt merged 1 commit intomasterfrom
feat/debug-mode-file-logging

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Jan 27, 2026

Summary

This PR adds a --debug flag that enables comprehensive debug logging to help troubleshoot issues when the agent doesn't return expected output.

Changes

New --debug flag

When --debug is passed:

  • All trace-level logs are written to ./debug.txt in the current working directory
  • Logs include:
    • Module paths (target)
    • Thread IDs and names
    • Source file paths and line numbers
    • Timestamps
  • Non-blocking writer is used for performance
  • A confirmation message is printed to stderr showing the debug file location

Usage

# Start TUI with debug logging
cortex --debug

# Run a command with debug logging  
cortex --debug run "explain this code"

# Exec mode with debug logging
cortex --debug exec "run tests"

The generated debug.txt file will contain all Rust tracing events and internal diagnostics, which is invaluable for troubleshooting when the agent doesn't produce expected output.

Implementation Details

  • Uses tracing-appender for non-blocking file writing
  • Sets log level to trace to capture everything
  • Guard pattern ensures logs are properly flushed when the program exits
  • Works in both TUI and non-TUI modes

This adds a --debug flag that enables comprehensive debug logging to help
troubleshoot issues when the agent doesn't return expected output.

When --debug is passed:
- All trace-level logs are written to ./debug.txt in the current directory
- Logs include module paths, thread IDs, thread names, source files, and line numbers
- Non-blocking writer is used for performance
- A message is printed to stderr confirming the debug file location

This is useful for diagnosing issues in both TUI and non-TUI modes.
@echobt echobt merged commit ac1a285 into master Jan 27, 2026
@echobt echobt deleted the feat/debug-mode-file-logging branch January 27, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants