-
Notifications
You must be signed in to change notification settings - Fork 60
Add option to set logging level #795
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
Conversation
4c9c349 to
4a6bb03
Compare
4450c8b to
e62cb3c
Compare
dfe60f2 to
5117acd
Compare
| return f.read() | ||
| except Exception as e: | ||
| logger.error(f"Failed to read file {file_path}. {e}") | ||
| logger.debug(f"Failed to read file {file_path}. {e}") |
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.
Why changing it from error to debug?
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.
Because when read_file failed to find file, it will not break the main functionality, which might lead to numerous unnecessary log entries at the error level. This could fill the console with non-critical error messages, potentially masking more significant issues. This change could help keep the log output more relevant and manageable.
| # TODO: allow the user to setup the logging level? | ||
| logging.basicConfig(stream=sys.stdout, level=logging.INFO) | ||
| logger = logging.getLogger("ODSC_AQUA") | ||
| logger = logging.getLogger("ads.aqua") |
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.
We can import this logger from ads.aqua?
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.
Hi QQ, import this logger from ads.aqua causing circular import during testing. So I use getLogger at here instead.
| logger = logging.getLogger(__name__) | ||
| handler = logging.StreamHandler(sys.stdout) | ||
| logger.setLevel(logging.INFO) | ||
| ENV_VAR_LOG_LEVEL = "ADS_AQUA_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.
Just curious. Do we expect in the future to have a separate env var for every package? Wouldn't it be better to have one ENV var for entire ADS (ADS_LOG_LEVEL), and utilize it everywhere in the future?
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.
cc: @mayoor
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.
We can do an overhaul separately. I dont want to mislead the users to think that entire ADS respects the env variable. Hence, my suggestion to make it Aqua specific.
| return level | ||
|
|
||
|
|
||
| def configure_aqua_logger(): |
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 reuse the logger in ads.init?
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.
| logger = logging.getLogger(__name__) | ||
| handler = logging.StreamHandler(sys.stdout) | ||
| logger.setLevel(logging.INFO) | ||
| ENV_VAR_LOG_LEVEL = "ADS_AQUA_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.
We can do an overhaul separately. I dont want to mislead the users to think that entire ADS respects the env variable. Hence, my suggestion to make it Aqua specific.
Description
This PR aims to provide option to set logging level for AQUA API and CLI.
User experience
CLI: set through flag
--log-level=DEBUGAPI: set through env var
ADS_AQUA_LOG_LEVEL=DEBUGChanged
Testing