Skip to content
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

fix(ffi): ensure there's always a global directive for logs #4485

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jan 8, 2025

If it's present, we just let it untouched. Otherwise, we set it to error if it's missing. See code comment explaining why we need this.

This makes sure we log panics at the FFI layer, since the log_panics crate will use an error level, with a target that's likely unknown to the user providing the log filter configuration.

If it's present, we just let it untouched. Otherwise, we set it to
`error` if it's missing. See code comment explaining why we need this.
@bnjbvr bnjbvr marked this pull request as ready for review January 8, 2025 13:44
@bnjbvr bnjbvr requested a review from a team as a code owner January 8, 2025 13:44
@bnjbvr bnjbvr requested review from andybalaam and removed request for a team January 8, 2025 13:44
// If there's no global directive, and a non-empty set of module/crate
// directives, then logs from modules and crates *not* appearing in the list
// of directives will be silently swallowed. This is bad, especially at the
// `error` level, for which we always want to see logs (notably because the
Copy link
Member

Choose a reason for hiding this comment

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

The original reason for removing the global directive is to take zero chances that a 3rd party crate would log sensitive data, which would be hard to find and even harder to clean up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's a good point. I've implemented your suggestion to restrict this to only adding panic=error to the log filter line, since it's a more cautious choice.

Copy link

codecov bot commented Jan 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.10%. Comparing base (d649606) to head (353edfc).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4485      +/-   ##
==========================================
- Coverage   85.12%   85.10%   -0.03%     
==========================================
  Files         283      283              
  Lines       31775    31775              
==========================================
- Hits        27048    27041       -7     
- Misses       4727     4734       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


#[test]
fn test_do_nothing_when_provided() {
let mut filter = String::from("a=b,panic=error,c=d");
Copy link
Member

Choose a reason for hiding this comment

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

Might be better if this test said panic=info or something, if that is allowed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, will adjust, thanks!

@bnjbvr bnjbvr force-pushed the bnjbvr/tweak-log-filter-ffi branch from 83fb579 to 353edfc Compare January 8, 2025 15:23
@bnjbvr bnjbvr enabled auto-merge (squash) January 8, 2025 15:24
Copy link
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

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

Just tested out the new version and it works great!

@bnjbvr bnjbvr merged commit 34e9934 into main Jan 8, 2025
39 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/tweak-log-filter-ffi branch January 8, 2025 15:51
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.

5 participants