Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions google-cloud-bigquery-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@
<version>3.5.2</version>
<configuration>
<skip>${skipSurefire}</skip>
<systemPropertyVariables>
<JDBC_TESTS>true</JDBC_TESTS>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<JDBC_TESTS>true</JDBC_TESTS>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class BigQueryJdbcRootLogger {
private static final Logger logger = Logger.getLogger("com.google.cloud.bigquery");

private static final Logger storageLogger = Logger.getLogger("com.google.cloud.bigquery.storage");
private static final boolean isTest = Boolean.getBoolean("JDBC_TESTS");

private static Handler fileHandler = null;
private static Path currentLogPath = null;
Expand All @@ -51,6 +52,12 @@ class BigQueryJdbcRootLogger {
static {
logger.setUseParentHandlers(false);
storageLogger.setUseParentHandlers(true);
if (isTest) {
ConsoleHandler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(Level.SEVERE);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
consoleHandler.setLevel(Level.SEVERE);
consoleHandler.setLevel(Level.INFO);

consoleHandler.setFormatter(getFormatter());
logger.addHandler(consoleHandler);
}
}

public static Formatter getFormatter() {
Expand Down Expand Up @@ -111,13 +118,12 @@ private static void setHandler() throws IOException {
// If File handler exists, use it. Else create new one.
for (Handler h : logger.getHandlers()) {
if (h instanceof ConsoleHandler) {
h.close();
logger.removeHandler(h);
break;
}
if (h instanceof FileHandler) {
if (!isTest) {
h.close();
logger.removeHandler(h);
}
} else if (h instanceof FileHandler) {
fileHandler = h;
break;
}
Comment on lines +125 to 127
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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;
      }

}

Expand Down
Loading