-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add optional JSON logging #83
Conversation
Codecov Report
@@ Coverage Diff @@
## main #83 +/- ##
==========================================
- Coverage 96.31% 95.94% -0.38%
==========================================
Files 48 48
Lines 1874 1900 +26
==========================================
+ Hits 1805 1823 +18
- Misses 69 77 +8
|
45e2b3b
to
f04add6
Compare
I don't really understand what's happening here, when I run this locally it's telling me logging.py is even more covered than it was before:
|
self.project_name = project_name | ||
super().__init__(*args, **kwargs) | ||
|
||
def add_fields(self, log_record, record, message_dict): |
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'm tempted to ignore this block for the purposes of coverage. I tried to write some tests here but it's proving fairly difficult to get the mocks right.
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'm super surprised codecov says most of this isn't tested. Curious, if you put a debugger in here and run codemodder as pixeebot would, it does it it, right? That would tell me integration tests would test this but right now we only calc coverage based on unit tests. This makes sense bc the way we run integration tests with subprocess.run creates a separate process and pytest / cov can't calculate coverage there.
Is there any help from the python-json-logger docs in regards to testing? Does chatgpt help in any way here? If you've tried these avenues and felt like you've spent sufficient time, I would be ok with adding no-cover here though it does break my heart a little.
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 codepath is only covered if we use --log-format=json
which probably doesn't happen in any of the integration tests right now. This basically just boils down to level of effort vs reward right now and I can't afford to spend any more time trying to get this covered.
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.
Totally fine, ticket and move on. Could be a good starter task for someone who may join in the upcoming months or just an easy "end of day" task.
|
||
stderr_handler = logging.StreamHandler(sys.stderr) | ||
stderr_handler.setLevel(logging.ERROR) | ||
match log_format: |
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.
<3
7c59366
to
fd95622
Compare
Overview
Implement JSON logging per the logging spec