-
Notifications
You must be signed in to change notification settings - Fork 828
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
fix: logger should be generally quiet #1187
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1187 +/- ##
============================================
+ Coverage 68.63% 68.67% +0.04%
- Complexity 3830 3833 +3
============================================
Files 173 173
Lines 15997 15996 -1
Branches 2609 2609
============================================
+ Hits 10979 10986 +7
+ Misses 3784 3778 -6
+ Partials 1234 1232 -2 |
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.
I agree with some of the changes, however I think other lines should not be changed
@@ -125,7 +125,7 @@ private Properties loadDefaultProperties() throws IOException { | |||
} | |||
|
|||
if (cl == null) { | |||
LOGGER.log(Level.WARNING, "Can't find a classloader for the Driver; not loading driver configuration"); | |||
LOGGER.log(Level.FINE, "Can't find a classloader for the Driver; not loading driver configuration"); |
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.
+1 regarding this case.
On top of that, it makes sense to add a word on org/postgresql/driverconfig.properties
so it is clear which configuration was skipped.
@@ -232,7 +232,7 @@ public Connection connect(String url, Properties info) throws SQLException { | |||
} | |||
// parse URL and add more properties | |||
if ((props = parseURL(url, props)) == null) { | |||
LOGGER.log(Level.SEVERE, "Error in url: {0}", url); | |||
LOGGER.log(Level.FINE, "Error in url: {0}", url); |
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.
TL;DR: -1 for the change.
Am I missing a case?
I think this warning could never appear in properly configured setup, so I think this logging should be enabled by default, so it highlights errors in configuration.
Looking a bit more, I think it could make logging more detailed (e.g. move it inside parseURL
, so error messages are more focused).
@@ -260,7 +260,7 @@ public Connection connect(String url, Properties info) throws SQLException { | |||
thread.start(); | |||
return ct.getResult(timeout); | |||
} catch (PSQLException ex1) { | |||
LOGGER.log(Level.SEVERE, "Connection error: ", ex1); | |||
LOGGER.log(Level.FINE, "Connection error: ", ex1); |
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.
+1 The error is re-thrown, so logging level could be reduced.
@@ -270,7 +270,7 @@ public Connection connect(String url, Properties info) throws SQLException { | |||
"Your security policy has prevented the connection from being attempted. You probably need to grant the connect java.net.SocketPermission to the database server host and port that you wish to connect to."), | |||
PSQLState.UNEXPECTED_ERROR, ace); | |||
} catch (Exception ex2) { | |||
LOGGER.log(Level.SEVERE, "Unexpected connection error: ", ex2); | |||
LOGGER.log(Level.FINE, "Unexpected connection error: ", ex2); |
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.
+1
@@ -659,7 +659,7 @@ private static long timeout(Properties props) { | |||
try { | |||
return (long) (Float.parseFloat(timeout) * 1000); | |||
} catch (NumberFormatException e) { | |||
LOGGER.log(Level.WARNING, "Couldn't parse loginTimeout value: {0}", timeout); | |||
LOGGER.log(Level.FINE, "Couldn't parse loginTimeout value: {0}", timeout); |
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.
-1 as this happens in case user provides loginTimeout property and it gets ignored.
Does that really happen often?
I think this log message would appear just in case one tries to put invalid value, and it would warn that the value is ignored.
@@ -97,7 +97,7 @@ public Connection getConnection(String user, String password) throws SQLExceptio | |||
} | |||
return con; | |||
} catch (SQLException e) { | |||
LOGGER.log(Level.SEVERE, "Failed to create a {0} for {1} at {2}: {3}", | |||
LOGGER.log(Level.FINE, "Failed to create a {0} for {1} at {2}: {3}", |
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.
+1
@@ -1369,7 +1369,7 @@ public boolean isValid(int timeout) throws SQLException { | |||
// "current transaction aborted", assume the connection is up and running | |||
return true; | |||
} | |||
LOGGER.log(Level.WARNING, GT.tr("Validating connection."), e); | |||
LOGGER.log(Level.FINE, GT.tr("Validating connection."), e); |
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.
-1 The exception is not re-thrown, so hiding it by default might make "root cause analysis" harder.
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.
Yes, the exception is not re-thrown but the method returns a boolean indicating if the connection is Valid, the point of the method is not get the "root cause", is to validate the connection.
For instance if a connection pool every time it tries to borrow a connection check if is valid, this will flood the log for no reason.
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.
+1
@@ -88,17 +88,17 @@ public boolean isSSPISupported() { | |||
* won't have JNA and this will throw a NoClassDefFoundError. | |||
*/ | |||
if (!Platform.isWindows()) { | |||
LOGGER.log(Level.WARNING, "SSPI not supported: non-Windows host"); | |||
LOGGER.log(Level.FINE, "SSPI not supported: non-Windows host"); |
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.
+1
return false; | ||
} | ||
/* Waffle must be on the CLASSPATH */ | ||
Class.forName("waffle.windows.auth.impl.WindowsSecurityContextImpl"); | ||
return true; | ||
} catch (NoClassDefFoundError ex) { | ||
LOGGER.log(Level.WARNING, "SSPI unavailable (no Waffle/JNA libraries?)", ex); | ||
LOGGER.log(Level.FINE, "SSPI unavailable (no Waffle/JNA libraries?)", ex); |
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.
-1 as it might highlight configuration issues.
On the other hand, it could make sense to make this one-time-only log message (e.g. static boolean sspiUnavailable
in SSPIClient
class
@@ -63,7 +63,7 @@ public synchronized void releaseTimer() { | |||
} | |||
} else { | |||
// Should not get here under normal circumstance, probably a bug in app code. | |||
LOGGER.log(Level.WARNING, | |||
LOGGER.log(Level.FINE, |
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.
-1 as this should never happen, and the message highlights something fishy
84e7204
to
823d3ed
Compare
@jorsol , would you please rebase and add a |
Rebased and |
@@ -178,23 +172,18 @@ public QueryExecutor openConnectionImpl(HostSpec[] hostSpecs, String user, Strin | |||
|
|||
// Set SO_RECVBUF read buffer size | |||
int receiveBufferSize = PGProperty.RECEIVE_BUFFER_SIZE.getInt(info); | |||
if (receiveBufferSize > -1) { |
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.
AFAIK -1
was here to just use system default. Raising a warning for that case is not good
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.
Was that an intentional change?
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.
Reverted.
The logger used in the driver has some calls to levels WARNING and SEVERE this lower the level to FINE to make the logger quiet in some cases.
The logger used in the driver has some calls to levels WARNING and SEVERE, this lower the level to FINE to make the logger quiet.
Changing SEVERE to WARNING is not enough, as WARNING is higher than INFO the default global logging level.
fixes #1009
fixes #1162
closes #1149