Skip to content

fix(debug): Do not consider parent loggers for debug logging #4286

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 1 commit into from
Apr 14, 2025

Conversation

szokeasaurusrex
Copy link
Member

@szokeasaurusrex szokeasaurusrex commented Apr 14, 2025

This reverts commit 3793084, which made the SDK consider parent loggers when determining if the Sentry SDK should log debug messages.

However, we should not consider parent loggers, since we only want the SDK to log debug messages when configured to do so via debug=True (in sentry_sdk.init), the SENTRY_DEBUG environment variable, or via a specific logger configuration for sentry_sdk.errors. With 3793084, a custom root logger configuration would also cause SDK logs to be emitted.

The issue 3793084 was meant to fix (#3944) will require a different fix.

Fixes #4266

@szokeasaurusrex szokeasaurusrex requested a review from a team as a code owner April 14, 2025 10:45
@szokeasaurusrex szokeasaurusrex requested review from sentrivana and removed request for a team April 14, 2025 10:45
Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

Ty!

Copy link

codecov bot commented Apr 14, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 79.53%. Comparing base (be22912) to head (cf235b6).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/debug.py 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4286      +/-   ##
==========================================
+ Coverage   79.51%   79.53%   +0.02%     
==========================================
  Files         142      142              
  Lines       15907    15907              
  Branches     2723     2723              
==========================================
+ Hits        12648    12652       +4     
+ Misses       2390     2389       -1     
+ Partials      869      866       -3     
Files with missing lines Coverage Δ
sentry_sdk/debug.py 91.30% <0.00%> (ø)

... and 2 files with indirect coverage changes

This reverts commit 3793084, which made the SDK consider parent loggers when determining if the Sentry SDK should log debug messages.

However, we should not consider parent loggers, since we only want the SDK to log debug messages when configured to do so via `debug=True` (in `sentry_sdk.init`), the `SENTRY_DEBUG` environment variable, or via a specific logger configuration for `sentry_sdk.errors`. With 3793084, a custom root logger configuration would also cause SDK logs to be emitted.

The issue 3793084 was meant to fix (#3944) appears to have been caused by user error, not a bug in the SDK.

Fixes #4266
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/fix-logging branch from 0b21ae2 to cf235b6 Compare April 14, 2025 12:04
@szokeasaurusrex szokeasaurusrex merged commit 5689bc0 into master Apr 14, 2025
137 of 138 checks passed
@szokeasaurusrex szokeasaurusrex deleted the szokeasaurusrex/fix-logging branch April 14, 2025 13:41
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.

sentry_sdk.errors DEBUG logs are emitted without debug=True
2 participants