This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Move logging to %-style formatting [#837] #1132
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…with NonPii in those logs that are currently using %-style formatting.
…ents in Pii, such as raw exceptions.
pattisdr
changed the title
[Draft] Move logging to %-style formatting [#837]
Move logging to %-style formatting [#837]
Aug 23, 2022
pattisdr
commented
Aug 23, 2022
@@ -97,7 +97,6 @@ disable=[ | |||
"import-outside-toplevel", | |||
"invalid-name", | |||
"line-too-long", | |||
"logging-fstring-interpolation", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will keep us from using f-strings in our logs going forward.
Comment on lines
51
to
+55
|
||
Don't mask numeric values as this can throw errors in consumers | ||
format strings. | ||
""" | ||
|
||
if isinstance(parameter, (NotPii, Number)): | ||
return parameter | ||
Logging args must be specifically wrapped in Pii in order to mask. | ||
|
||
return MASKED | ||
""" | ||
return MASKED if isinstance(parameter, Pii) else parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flips to mask if PII instead of "don't mask if not PII or it's a number"
sanders41
reviewed
Aug 23, 2022
src/fidesops/ops/migrations/versions/55d61eb8ed12_add_default_policies.py
Outdated
Show resolved
Hide resolved
…atting # Conflicts: # CHANGELOG.md # src/fidesops/main.py # src/fidesops/ops/core/config.py
sanders41
reviewed
Aug 23, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I caught them all last round, but saw a couple more }. I did a search this time and these look to be the last 2.
src/fidesops/ops/service/privacy_request/request_runner_service.py
Outdated
Show resolved
Hide resolved
src/fidesops/ops/service/processors/post_processor_strategy/post_processor_strategy_filter.py
Outdated
Show resolved
Hide resolved
sanders41
approved these changes
Aug 24, 2022
sanders41
pushed a commit
that referenced
this pull request
Sep 22, 2022
* Add a new Pii class and use it to wrap arguments not already wrapped with NonPii in those logs that are currently using %-style formatting. * Switch logging formatting to %-style instead of f-string. * Continue to address lingering f string instances, and wrap some arguments in Pii, such as raw exceptions. * Remove NotPii class and update tests. * Adjust errors made in %-style conversion. * Remove accidental Pii on print statements, update some PII wrappings. * Adjust string formatting of newly added log. * Update Changelog. * Fix missed closing curly brackets. * Remove missed curly brackets.
14 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
❗ Get up-to-date with main before merging, so we pick up any newly-added logs.
Purpose
The "f string" formatting we use across the majority of our logs make them not maskable. Update logging across the entire application to be a format we can mask and switch logging strategy to be Pii instead of NotPii.
There's a side benefit of using "%" formatting in that it is evaluated lazily and only calculated if the message is actually emitted.
Changes
Checklist
CHANGELOG.md
fileCHANGELOG.md
file is being appended toUnreleased
section in an appropriate category. Add a new category from the list at the top of the file if the needed one isn't already there.Run Unsafe PR Checks
label has been applied, and checks have passed, if this PR touches any external servicesTicket
Fixes #837