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

Improve logging of bare exceptions and other cleanups. #922

Merged
merged 1 commit into from
Jul 14, 2022
Merged

Improve logging of bare exceptions and other cleanups. #922

merged 1 commit into from
Jul 14, 2022

Conversation

thetorpedodog
Copy link
Contributor

This change finds a few places where log.[somelevel](some_exc)
was called and rewrites them to provide more information. Also updates
other logging statements in the same files to use logging best practices
(always put a static message in the first parameter, only substitute
variables in with % expressions).

@welcome
Copy link

welcome bot commented Jul 13, 2022

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

This change finds a few places where `log.[somelevel](some_exc)`
was called and rewrites them to provide more information. Also updates
other logging statements in the same files to use logging best practices
(always put a static message in the first parameter, only substitute
variables in with `%` expressions).
@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2022

Codecov Report

Merging #922 (18063db) into main (8a0caf6) will decrease coverage by 0.00%.
The diff coverage is 81.25%.

@@            Coverage Diff             @@
##             main     #922      +/-   ##
==========================================
- Coverage   72.29%   72.29%   -0.01%     
==========================================
  Files          65       65              
  Lines        7978     7976       -2     
  Branches     1332     1332              
==========================================
- Hits         5768     5766       -2     
  Misses       1804     1804              
  Partials      406      406              
Impacted Files Coverage Δ
jupyter_server/base/handlers.py 66.27% <50.00%> (ø)
jupyter_server/services/kernels/kernelmanager.py 78.64% <66.66%> (ø)
jupyter_server/extension/manager.py 92.68% <100.00%> (-0.08%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a0caf6...18063db. Read the comment docs.

@Zsailer
Copy link
Member

Zsailer commented Jul 14, 2022

(always put a static message in the first parameter, only substitute variables in with % expressions).

Interesting. I had no idea that this was considered a best practice for optimization (documentation to prove it!)

@blink1073 blink1073 merged commit cb9c5ed into jupyter-server:main Jul 14, 2022
@welcome
Copy link

welcome bot commented Jul 14, 2022

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

@blink1073
Copy link
Contributor

@meeseeksdev please backport to 1.x

@lumberbot-app
Copy link

lumberbot-app bot commented Jul 14, 2022

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 1.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 cb9c5edff77c2146d0e66425a82c7b6125b5039e
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #922: Improve logging of bare exceptions and other cleanups.'
  1. Push to a named branch:
git push YOURFORK 1.x:auto-backport-of-pr-922-on-1.x
  1. Create a PR against branch 1.x, I would have named this PR:

"Backport PR #922 on branch 1.x (Improve logging of bare exceptions and other cleanups.)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@thetorpedodog
Copy link
Contributor Author

Interesting. I had no idea that this was considered a best practice for optimization (documentation to prove it!)

It’s also, strictly speaking, a correctness issue—if you have

message_contents = "60%savory"
log.info(f"this beef is {message_contents}")

then the string that’s passed in will be:

this beef is 60%savory
               ^^ formatting directive!

but there's nothing to substitute in for the %s (which you didn’t intend to be substituted anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants