-
Notifications
You must be signed in to change notification settings - Fork 134
chore(jdbc): add console logs during tests #4130
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -51,6 +52,12 @@ class BigQueryJdbcRootLogger { | |
| static { | ||
| logger.setUseParentHandlers(false); | ||
| storageLogger.setUseParentHandlers(true); | ||
| if (isTest) { | ||
| ConsoleHandler consoleHandler = new ConsoleHandler(); | ||
| consoleHandler.setLevel(Level.SEVERE); | ||
| consoleHandler.setFormatter(getFormatter()); | ||
| logger.addHandler(consoleHandler); | ||
| } | ||
| } | ||
|
|
||
| public static Formatter getFormatter() { | ||
|
|
@@ -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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The } else if (h instanceof FileHandler) {
fileHandler = h;
break;
} |
||
| } | ||
|
|
||
|
|
||
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.
The console handler's level is set to
SEVERE, which will only show logs of levelSEVEREor 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.SEVEREis very restrictive. Consider using a less restrictive level likeLevel.INFOto capture more log details during test runs.