chore(jdbc): add console logs during tests#4130
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 enhances the debugging experience during test runs by enabling console logging. By setting a system property during Maven test execution, the logging framework is configured to output logs directly to the console, providing immediate visibility into test behavior without requiring a debugger. This change aims to streamline the process of identifying and resolving test failures. Highlights
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 aims to add console logging during test runs, which is a helpful addition for debugging. The changes in pom.xml to enable this are correct. In BigQueryJdbcRootLogger.java, I've identified a couple of areas for improvement. Firstly, the log level for the new console handler is set to SEVERE, which is highly restrictive and may not align with the goal of getting more detailed logs; I've suggested a more permissive level. Secondly, a break statement was removed from a loop, which I recommend restoring for efficiency and to prevent potential subtle issues. My detailed feedback is in the comments below.
| storageLogger.setUseParentHandlers(true); | ||
| if (isTest) { | ||
| ConsoleHandler consoleHandler = new ConsoleHandler(); | ||
| consoleHandler.setLevel(Level.SEVERE); |
There was a problem hiding this comment.
The console handler's level is set to SEVERE, which will only show logs of level SEVERE or higher. The pull request description states, "If we can't figure out why test is failing with logs-only, we need more logs", which suggests more verbose logging is desired. Level.SEVERE is very restrictive. Consider using a less restrictive level like Level.INFO to capture more log details during test runs.
| consoleHandler.setLevel(Level.SEVERE); | |
| consoleHandler.setLevel(Level.INFO); |
| } else if (h instanceof FileHandler) { | ||
| fileHandler = h; | ||
| break; | ||
| } |
There was a problem hiding this comment.
The break statement was removed from this block. It should be restored to avoid iterating unnecessarily after the FileHandler is found. This also prevents a potential change in behavior from using the first found handler to the last one, in the unlikely case of multiple FileHandler instances.
} else if (h instanceof FileHandler) {
fileHandler = h;
break;
}
Enable logging to console during test runs.
The idea behind this change is "If we can't figure out why test is failing with logs-only, we need more logs". Right now always have to run test with a debugger to really figure out what's wrong.