Skip to content

Commit 6da3ca3

Browse files
SNOW-1652680: Limit logging on std out and info level (#1980)
1 parent 852b2d9 commit 6da3ca3

21 files changed

+66
-72
lines changed

src/main/java/net/snowflake/client/config/SFClientConfigParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static SFClientConfig loadSFClientConfig(String configFilePath) throws IO
7373
File configFile = new File(derivedConfigFilePath);
7474
ObjectMapper objectMapper = new ObjectMapper();
7575
SFClientConfig clientConfig = objectMapper.readValue(configFile, SFClientConfig.class);
76-
logger.info(
76+
logger.debug(
7777
"Reading values logLevel {} and logPath {} from client configuration",
7878
clientConfig.getCommonProps().getLogLevel(),
7979
clientConfig.getCommonProps().getLogPath());

src/main/java/net/snowflake/client/core/CredentialManager.java

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ private void initSecureStorageManager() {
3232
logger.error("Unsupported Operating System. Expected: OSX, Windows, Linux", false);
3333
}
3434
} catch (NoClassDefFoundError error) {
35-
logger.info(
36-
"JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.",
37-
false);
35+
logMissingJnaJarForSecureLocalStorage();
3836
}
3937
}
4038

@@ -97,9 +95,7 @@ void fillCachedMfaToken(SFLoginInput loginInput) throws SFException {
9795
synchronized void fillCachedCredential(SFLoginInput loginInput, String credType)
9896
throws SFException {
9997
if (secureStorageManager == null) {
100-
logger.info(
101-
"JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.",
102-
false);
98+
logMissingJnaJarForSecureLocalStorage();
10399
return;
104100
}
105101

@@ -109,9 +105,7 @@ synchronized void fillCachedCredential(SFLoginInput loginInput, String credType)
109105
secureStorageManager.getCredential(
110106
loginInput.getHostFromServerUrl(), loginInput.getUserName(), credType);
111107
} catch (NoClassDefFoundError error) {
112-
logger.info(
113-
"JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.",
114-
false);
108+
logMissingJnaJarForSecureLocalStorage();
115109
return;
116110
}
117111

@@ -183,19 +177,15 @@ synchronized void writeTemporaryCredential(SFLoginInput loginInput, String cred,
183177
}
184178

185179
if (secureStorageManager == null) {
186-
logger.info(
187-
"JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.",
188-
false);
180+
logMissingJnaJarForSecureLocalStorage();
189181
return;
190182
}
191183

192184
try {
193185
secureStorageManager.setCredential(
194186
loginInput.getHostFromServerUrl(), loginInput.getUserName(), credType, cred);
195187
} catch (NoClassDefFoundError error) {
196-
logger.info(
197-
"JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.",
198-
false);
188+
logMissingJnaJarForSecureLocalStorage();
199189
}
200190
}
201191

@@ -222,18 +212,20 @@ void deleteMfaTokenCache(String host, String user) {
222212
*/
223213
synchronized void deleteTemporaryCredential(String host, String user, String credType) {
224214
if (secureStorageManager == null) {
225-
logger.info(
226-
"JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.",
227-
false);
215+
logMissingJnaJarForSecureLocalStorage();
228216
return;
229217
}
230218

231219
try {
232220
secureStorageManager.deleteCredential(host, user, credType);
233221
} catch (NoClassDefFoundError error) {
234-
logger.info(
235-
"JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.",
236-
false);
222+
logMissingJnaJarForSecureLocalStorage();
237223
}
238224
}
225+
226+
private static void logMissingJnaJarForSecureLocalStorage() {
227+
logger.warn(
228+
"JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.",
229+
false);
230+
}
239231
}

src/main/java/net/snowflake/client/core/FileCacheManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ FileCacheManager build() {
165165
this.cacheLockFile =
166166
new File(this.cacheFile.getParentFile(), this.baseCacheFileName + ".lck");
167167
} catch (IOException | SecurityException ex) {
168-
logger.info("Failed to touch the cache file. Ignored. {}", cacheFileTmp.getAbsoluteFile());
168+
logger.debug("Failed to touch the cache file. Ignored. {}", cacheFileTmp.getAbsoluteFile());
169169
}
170170
return this;
171171
}

src/main/java/net/snowflake/client/core/IncidentUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private static void writeVmMetrics(JsonGenerator json, VirtualMachineMetrics vm)
206206
// This function can throw an error with java 11.
207207
json.writeNumberField("fd_usage", vm.fileDescriptorUsage());
208208
} catch (Exception e) {
209-
logger.info("Error writing fd_usage", e);
209+
logger.debug("Error writing fd_usage", e);
210210
}
211211

212212
json.writeFieldName("thread-states");

src/main/java/net/snowflake/client/core/SFBaseSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ private void logHttpClientInitInfo(HttpClientSettingsKey key) {
687687
key.getProxyUser(),
688688
key.getProxyPassword().isEmpty() ? "not set" : "set");
689689
} else {
690-
logger.info(
690+
logger.debug(
691691
"Driver OCSP mode: {}, gzip disabled: {} and no proxy",
692692
key.getOcspMode(),
693693
key.getGzipDisabled());

src/main/java/net/snowflake/client/core/SFSession.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ public synchronized void open() throws SFException, SnowflakeSQLException {
794794
// start heartbeat for this session so that the master token will not expire
795795
startHeartbeatForThisSession();
796796
stopwatch.stop();
797-
logger.info("Session {} opened in {} ms.", getSessionId(), stopwatch.elapsedMillis());
797+
logger.debug("Session {} opened in {} ms.", getSessionId(), stopwatch.elapsedMillis());
798798
}
799799

800800
/**
@@ -937,7 +937,7 @@ public void close() throws SFException, SnowflakeSQLException {
937937
}
938938

939939
stopwatch.stop();
940-
logger.info(
940+
logger.debug(
941941
"Session {} has been successfully closed in {} ms",
942942
getSessionId(),
943943
stopwatch.elapsedMillis());

src/main/java/net/snowflake/client/core/SFStatement.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,11 @@ public Object executeHelper(
435435
}
436436
if (numBinds > 0 && session.getPreparedStatementLogging()) {
437437
if (numBinds > MAX_BINDING_PARAMS_FOR_LOGGING) {
438-
logger.info(
438+
logger.debug(
439439
"Number of binds exceeds logging limit. Printing off {} binding parameters.",
440440
MAX_BINDING_PARAMS_FOR_LOGGING);
441441
} else {
442-
logger.info("Printing off {} binding parameters.", numBinds);
442+
logger.debug("Printing off {} binding parameters.", numBinds);
443443
}
444444
int counter = 0;
445445
// if it's an array bind, print off the first few rows from each column.
@@ -458,7 +458,7 @@ public Object executeHelper(
458458
rows += bindRows.get(i) + ", ";
459459
}
460460
rows += "]";
461-
logger.info("Column {}: {}", entry.getKey(), rows);
461+
logger.debug("Column {}: {}", entry.getKey(), rows);
462462
counter += numRowsPrinted;
463463
if (counter >= MAX_BINDING_PARAMS_FOR_LOGGING) {
464464
break;
@@ -472,7 +472,7 @@ public Object executeHelper(
472472
break;
473473
}
474474
counter++;
475-
logger.info("Column {}: {}", entry.getKey(), entry.getValue().getValue());
475+
logger.debug("Column {}: {}", entry.getKey(), entry.getValue().getValue());
476476
}
477477
}
478478
}

src/main/java/net/snowflake/client/core/SecureStorageAppleManager.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ private SecureStorageAppleManager() {
2222
}
2323

2424
public static SecureStorageAppleManager builder() {
25-
logger.info("Using Apple Keychain as a token cache storage");
25+
logger.debug("Using Apple Keychain as a token cache storage");
2626
return new SecureStorageAppleManager();
2727
}
2828

2929
public SecureStorageStatus setCredential(String host, String user, String type, String cred) {
3030
if (Strings.isNullOrEmpty(cred)) {
31-
logger.info("No credential provided", false);
31+
logger.debug("No credential provided", false);
3232
return SecureStorageStatus.SUCCESS;
3333
}
3434

@@ -53,7 +53,7 @@ public SecureStorageStatus setCredential(String host, String user, String type,
5353
}
5454

5555
if (errCode != SecurityLib.ERR_SEC_SUCCESS && errCode != SecurityLib.ERR_SEC_ITEM_NOT_FOUND) {
56-
logger.info(
56+
logger.warn(
5757
String.format(
5858
"Failed to check the existence of the item in keychain. Error code = %d",
5959
Native.getLastError()));
@@ -81,7 +81,7 @@ public SecureStorageStatus setCredential(String host, String user, String type,
8181
}
8282

8383
if (errCode != SecurityLib.ERR_SEC_SUCCESS) {
84-
logger.info(
84+
logger.warn(
8585
String.format(
8686
"Failed to set/modify the item in keychain. Error code = %d", Native.getLastError()));
8787
return SecureStorageStatus.FAILURE;
@@ -115,14 +115,14 @@ public String getCredential(String host, String user, String type) {
115115
}
116116

117117
if (errCode != SecurityLib.ERR_SEC_SUCCESS) {
118-
logger.info(
118+
logger.warn(
119119
String.format(
120120
"Failed to find the item in keychain or item not exists. Error code = %d",
121121
Native.getLastError()));
122122
return null;
123123
}
124124
if (dataLength[0] == 0 || data[0] == null) {
125-
logger.info("Found empty item or no item is found", false);
125+
logger.warn("Found empty item or no item is found", false);
126126
return null;
127127
}
128128

@@ -162,7 +162,7 @@ public SecureStorageStatus deleteCredential(String host, String user, String typ
162162
}
163163

164164
if (errCode != SecurityLib.ERR_SEC_SUCCESS && errCode != SecurityLib.ERR_SEC_ITEM_NOT_FOUND) {
165-
logger.info(
165+
logger.warn(
166166
String.format(
167167
"Failed to delete the item in keychain. Error code = %d", Native.getLastError()));
168168
return SecureStorageStatus.FAILURE;
@@ -174,7 +174,7 @@ public SecureStorageStatus deleteCredential(String host, String user, String typ
174174
}
175175

176176
if (errCode != SecurityLib.ERR_SEC_SUCCESS) {
177-
logger.info(
177+
logger.warn(
178178
String.format(
179179
"Failed to delete the item in keychain. Error code = %d", Native.getLastError()));
180180
return SecureStorageStatus.FAILURE;

src/main/java/net/snowflake/client/core/SecureStorageLinuxManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private SecureStorageLinuxManager() {
4141
.setCacheExpirationInSeconds(CACHE_EXPIRATION_IN_SECONDS)
4242
.setCacheFileLockExpirationInSeconds(CACHE_FILE_LOCK_EXPIRATION_IN_SECONDS)
4343
.build();
44-
logger.info(
44+
logger.debug(
4545
"Using temporary file: {} as a token cache storage", fileCacheManager.getCacheFilePath());
4646
}
4747

@@ -70,7 +70,7 @@ private ObjectNode localCacheToJson() {
7070
public synchronized SecureStorageStatus setCredential(
7171
String host, String user, String type, String token) {
7272
if (Strings.isNullOrEmpty(token)) {
73-
logger.info("No token provided", false);
73+
logger.warn("No token provided", false);
7474
return SecureStorageStatus.SUCCESS;
7575
}
7676

src/main/java/net/snowflake/client/core/SecureStorageWindowsManager.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ private SecureStorageWindowsManager() {
3333
}
3434

3535
public static SecureStorageWindowsManager builder() {
36-
logger.info("Using Windows Credential Manager as a token cache storage");
36+
logger.debug("Using Windows Credential Manager as a token cache storage");
3737
return new SecureStorageWindowsManager();
3838
}
3939

4040
public SecureStorageStatus setCredential(String host, String user, String type, String token) {
4141
if (Strings.isNullOrEmpty(token)) {
42-
logger.info("No token provided", false);
42+
logger.warn("No token provided", false);
4343
return SecureStorageStatus.SUCCESS;
4444
}
4545

@@ -63,13 +63,13 @@ public SecureStorageStatus setCredential(String host, String user, String type,
6363
}
6464

6565
if (!ret) {
66-
logger.info(
66+
logger.warn(
6767
String.format(
6868
"Failed to write to Windows Credential Manager. Error code = %d",
6969
Native.getLastError()));
7070
return SecureStorageStatus.FAILURE;
7171
}
72-
logger.info("Wrote to Windows Credential Manager successfully", false);
72+
logger.debug("Wrote to Windows Credential Manager successfully", false);
7373

7474
return SecureStorageStatus.SUCCESS;
7575
}
@@ -90,7 +90,7 @@ public String getCredential(String host, String user, String type) {
9090
}
9191

9292
if (!ret) {
93-
logger.info(
93+
logger.warn(
9494
String.format(
9595
"Failed to read target or could not find it in Windows Credential Manager. Error code = %d",
9696
Native.getLastError()));
@@ -104,12 +104,12 @@ public String getCredential(String host, String user, String type) {
104104

105105
if (SecureStorageWindowsCredentialType.typeOf(cred.Type)
106106
!= SecureStorageWindowsCredentialType.CRED_TYPE_GENERIC) {
107-
logger.info("Wrong type of credential. Expected: CRED_TYPE_GENERIC", false);
107+
logger.warn("Wrong type of credential. Expected: CRED_TYPE_GENERIC", false);
108108
return null;
109109
}
110110

111111
if (cred.CredentialBlobSize == 0) {
112-
logger.info("Returned credential is empty", false);
112+
logger.debug("Returned credential is empty", false);
113113
return null;
114114
}
115115

@@ -137,7 +137,7 @@ public SecureStorageStatus deleteCredential(String host, String user, String typ
137137
}
138138

139139
if (!ret) {
140-
logger.info(
140+
logger.warn(
141141
String.format(
142142
"Failed to delete target in Windows Credential Manager. Error code = %d",
143143
Native.getLastError()));

0 commit comments

Comments
 (0)