Skip to content

Conversation

@mingkang111
Copy link
Member

@mingkang111 mingkang111 commented Apr 19, 2024

Description

This PR aims to provide option to set logging level for AQUA API and CLI.

User experience

CLI: set through flag
--log-level=DEBUG
API: set through env var
ADS_AQUA_LOG_LEVEL=DEBUG

Changed

  • New feature: provide option to set logging level
  • Fixed logging message
  • Fixed logger import
  • Adjusted logging level for some verbose message.

Testing

Screenshot 2024-04-19 at 13 37 17

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Apr 19, 2024
@mingkang111 mingkang111 force-pushed the feature/set_logging_level branch from 4450c8b to e62cb3c Compare April 19, 2024 18:13
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}")
Copy link
Member

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?

Copy link
Member Author

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")
Copy link
Member

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?

Copy link
Member Author

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"
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @mayoor

Copy link
Member

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.

@mingkang111 mingkang111 merged commit ff40286 into feature/aquav1.0.1 Apr 22, 2024
@mingkang111 mingkang111 deleted the feature/set_logging_level branch April 22, 2024 17:36
return level


def configure_aqua_logger():
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mayoor , sorry for missing this comment. I have created another PR for resuing logger in ads.init: #800

logger = logging.getLogger(__name__)
handler = logging.StreamHandler(sys.stdout)
logger.setLevel(logging.INFO)
ENV_VAR_LOG_LEVEL = "ADS_AQUA_LOG_LEVEL"
Copy link
Member

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.

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

Labels

AQUA OCA Verified All contributors have signed the Oracle Contributor Agreement. ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants