-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feature/log level input checking #119
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -117,6 +117,28 @@ def set_log_level(level: str | int) -> int: | |||||
Previous log level | ||||||
""" | ||||||
# Map string name to logging level | ||||||
|
||||||
allowed_args = [ | ||||||
"CRITICAL", | ||||||
50, | ||||||
"ERROR", | ||||||
40, | ||||||
"WARNING", | ||||||
30, | ||||||
"INFO", | ||||||
20, | ||||||
"DEBUG", | ||||||
10, | ||||||
"NOTSET", | ||||||
0, | ||||||
# no logging of anything ever! | ||||||
logging.CRITICAL + 1, | ||||||
] | ||||||
|
||||||
err_str = f"Invalid arg: '{level}'. See doc string:\n{set_log_level.__doc__}" | ||||||
|
||||||
assert level in allowed_args, err_str | ||||||
|
||||||
if isinstance(level, str): | ||||||
level = logging._nameToLevel[level] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @calbaker optionally:
Suggested change
This would allow lowercase log level strings There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kylecarow , yea that sounds good. Could you make that change? |
||||||
# Extract previous log level and set new log level | ||||||
|
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.
Can we change instances of
fsim.utils.suppress_logging():
to a singlefsim.utils.disable_logging()
at the top of the file?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.
@kylecarow, I prefer the latter because I'd like it to be really obvious that we're suppressing logging so that we remember to fix the cause of the logging at some point in the future. Does this seem ok?
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 fine with either way really. Do you mean keeping it as is?