forked from thespianpy/Thespian
-
Notifications
You must be signed in to change notification settings - Fork 24
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
correcting logic to discern the lowest logging level #71
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cbfee0b
correcting logic to discern the lowest logging level
todd-cook 3688865
removed type hints.
todd-cook 1a401fb
corrected caller, since the default is logging.WARNING and not loggin…
todd-cook 487d231
changes as requested
todd-cook 162a184
further changes as requested
todd-cook File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
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.
It seems to me that this should exclude all
NOTSET
values, irrespective ofroot_val
, since allowing anyNOTSET
would result in a return value of 0 if there was noroot_val
specified.Also, the code for setting
root_val
does not ensure thatroot_val
is numeric: it could beNone
, or it could be an unrecognized string like"MyLevel"
, which would cause the>
comparison to throw aTypeError
exception.If there's no comparison to
root_val
here, then the reduction would lead to removingroot_val
as a variable and just putting the result of the corresponding expression in thelevels
array.Let me know if you disagree with my analysis here or if there's something I've missed.
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.
NOTSET is useful because the default logging level is warning. If somebody writes some library code and configs the logs somewhere and specifies NOTSET, it does log everything, but if a root logger specifies a level then it supercedes the NOTSET value. But if a logging config had all NOTSET values, and we discarded them, then the configured logging level would default to WARNING, which seems to violate the principle of least surprise.
Also, it looks like root value can be none:
I like this validation, so I added it to the doctests.
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've adjusted the logic. Invalid strings blow up the underlying Python API, so I think that error is fair game.
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 like those two logDefs as well, although I don't see that you added them to the doctests.
I agree on the unrecognized strings issue, it's reasonable to have similar behavior.
I'm not seeing behavior where
NOTSET
logs everything. See https://gist.github.com/kquick/d554a8b4de5541eb48c0bc1b14080fff which is careful to run a separate python for each configuration. I believe the last output set is the case you indicated should log everything but I see only WARNING and ERROR logging from that output (shown in this gist: https://gist.github.com/kquick/98eac6e6c55fa14fe3fbb19d671ed4b2)These are the two cases that will still fail:
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.
NOTSET on the root level logs everything, but NOTSET on another level besides root, logs at the root level, and if unintialized the logging level goes to WARNING.
I added a 6th test case to your gist that I co-opted.
https://gist.github.com/todd-cook/883662ba19eb5a3bb8b372733ec7f6a4
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.
see: https://gist.github.com/todd-cook/883662ba19eb5a3bb8b372733ec7f6a4#file-testlog-py-L43-L61
and output at:
https://gist.github.com/todd-cook/883662ba19eb5a3bb8b372733ec7f6a4#file-testlog-py-L114-L135
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.
So many different combinations and effects! The latest
get_min_log_level
in this PR will return the wrong value for case 4 and case 5 if you add those to the doctests.Also, you can change the doctests from:
to the following which will provide more information for when the tests fail: