Skip to content

Add --debug option #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 4, 2025
Merged

Add --debug option #177

merged 4 commits into from
Apr 4, 2025

Conversation

Pennycook
Copy link
Contributor

Related issues

Proposed changes

  • Prevent debug information from leaking accidentally via something like -vvvvvvvv.
  • Add an explicit --debug option to enable debug mode.
  • Display log.debug() messages only in debug mode.
  • Display traceback for top-level (i.e., uncaught) exceptions in debug mode.

I'm mainly adding this for myself, because it's really inconvenient to not be able to see the traceback when developing and testing work-in-progress features.

Rather than hiding this in some sort of developer branch, though, I think there is value in exposing it to end-users (as long as it's via an explicit opt-in, as I've proposed here). If we provide a --debug flag to generate debug logs and a traceback, users can give us much better bug reports. This is the main reason I'm trying to sneak this in ahead of 2.0 -- I'm hoping that we'll be able to attract some new users, which will probably lead to new bug reports.

Previously, specifying enough -v options made DEBUG messages visible.

Signed-off-by: John Pennycook <[email protected]>
Without --debug, both cbi.log and the terminal are restricted to displaying
only info, warning and error messages.

With --debug, cbi.log includes debug messages by default, but the terminal
displays debug messages only with sufficient --verbose flags.

Signed-off-by: John Pennycook <[email protected]>
The logging module already has support for this via the exc_info argument.

Making this work requires a small change to our custom Formatter, since it's
the Formatter's job to inspect exc_info and include the traceback in the
string output.

Signed-off-by: John Pennycook <[email protected]>
@Pennycook Pennycook added the ux Issues and PRs pertaining to user experience label Mar 21, 2025
@Pennycook Pennycook added this to the 2.0.0 milestone Mar 21, 2025
@Pennycook Pennycook requested a review from laserkelvin March 21, 2025 11:19
@Pennycook
Copy link
Contributor Author

The coverage CI is failing because we still don't have a good way to automate testing of the functionality in __main__.

I don't want to solve that wider issue as part of this PR, so I'd like to defer it until later.

Copy link
Contributor

@laserkelvin laserkelvin left a comment

Choose a reason for hiding this comment

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

LGTM

One suggestion is if we're including a --debug mode, do we want to omnibus anything that might make bug reports easier?

e.g. have it dump CBI git hash information at the top, Python version, etc.

@Pennycook
Copy link
Contributor Author

One suggestion is if we're including a --debug mode, do we want to omnibus anything that might make bug reports easier?

e.g. have it dump CBI git hash information at the top, Python version, etc.

That's a really good idea. I'll add something before merging this in.

@Pennycook
Copy link
Contributor Author

The changes in 0fd1c27 will print a message like this at the beginning of the log:

debug: Code Base Investigator 1.2.0; Python 3.12.3 (main, Feb  4 2025, 14:48:35) [GCC 13.3.0]

Including something like the git commit hash in the message would require a dynamic version. I figured out how to do this, but I'm going to introduce it in a separate follow-up PR to make sure that we catch all the version strings (e.g., the ones in cbi-cov and cbi-tree).

@Pennycook Pennycook merged commit c23c69d into intel:main Apr 4, 2025
3 of 4 checks passed
@Pennycook Pennycook deleted the feature/debug branch April 4, 2025 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ux Issues and PRs pertaining to user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a way to run in debug mode
2 participants