Add log level settings for auto skills#883
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces enhanced logging flexibility by allowing the log level to be controlled via an environment variable. This change streamlines the process of adjusting logging verbosity, which is crucial for debugging and monitoring, by centralizing the configuration and enabling runtime modifications without requiring application restarts. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces functionality to configure the logger level via the LOG_LEVEL environment variable. The changes are implemented in auto_skills.py and utils/logger.py, with a new helper function refresh_log_level to centralize some of this logic. My review focuses on further reducing code duplication by leveraging this new helper function more effectively and identifying another opportunity for consolidation within utils/logger.py to improve maintainability.
| log_level_str = os.getenv('LOG_LEVEL', 'INFO').upper() | ||
| log_level = getattr(logging, log_level_str, logging.INFO) | ||
|
|
||
| # Update logger level to respect current LOG_LEVEL env var | ||
| logger.setLevel(log_level) | ||
| for handler in logger.handlers: | ||
| handler.setLevel(log_level) |
There was a problem hiding this comment.
To avoid code duplication, you can use the new refresh_log_level function that you've added in ms_agent/utils/logger.py. This will make the code more maintainable.
You'll need to import it at the top of the file:
from ms_agent.utils.logger import get_logger, refresh_log_level| log_level_str = os.getenv('LOG_LEVEL', 'INFO').upper() | |
| log_level = getattr(logging, log_level_str, logging.INFO) | |
| # Update logger level to respect current LOG_LEVEL env var | |
| logger.setLevel(log_level) | |
| for handler in logger.handlers: | |
| handler.setLevel(log_level) | |
| log_level = refresh_log_level(logger) |
| target_logger.setLevel(log_level_int) | ||
| for handler in target_logger.handlers: | ||
| handler.setLevel(log_level_int) |
There was a problem hiding this comment.
This logic to set the level on the logger and its handlers is duplicated in the get_logger function (lines 57-59). To improve maintainability and avoid duplication, consider extracting this block into a private helper function, e.g., _set_level(logger, level), and call it from both get_logger and refresh_log_level.
No description provided.