Skip to content

Commit

Permalink
SNOW-1652680: Bring back some logging messages to info for files, clo…
Browse files Browse the repository at this point in the history
…ud and proxy operations
  • Loading branch information
sfc-gh-dprzybysz committed Dec 4, 2024
1 parent f62a978 commit 60a139d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,31 @@ public class SFClientConfigParser {
*/
public static SFClientConfig loadSFClientConfig(String configFilePath) throws IOException {
if (configFilePath != null) {
logger.debug("Attempting to enable easy logging with file path {}", configFilePath);
logger.info("Attempting to enable easy logging with file path {}", configFilePath);
}
String derivedConfigFilePath = null;
if (configFilePath != null && !configFilePath.isEmpty()) {
// 1. Try to read the file at configFilePath.
logger.debug("Using config file specified from connection string: {}", configFilePath);
logger.info("Using config file specified from connection string: {}", configFilePath);
derivedConfigFilePath = configFilePath;
} else if (System.getenv().containsKey(SF_CLIENT_CONFIG_ENV_NAME)) {
// 2. If SF_CLIENT_CONFIG_ENV_NAME is set, read from env.
String filePath = systemGetEnv(SF_CLIENT_CONFIG_ENV_NAME);
logger.debug("Using config file specified from environment variable: {}", filePath);
logger.info("Using config file specified from environment variable: {}", filePath);
derivedConfigFilePath = filePath;
} else {
// 3. Read SF_CLIENT_CONFIG_FILE_NAME from where jdbc jar is loaded.
String driverLocation =
Paths.get(getConfigFilePathFromJDBCJarLocation(), SF_CLIENT_CONFIG_FILE_NAME).toString();
if (Files.exists(Paths.get(driverLocation))) {
logger.debug("Using config file specified from driver directory: {}", driverLocation);
logger.info("Using config file specified from driver directory: {}", driverLocation);
derivedConfigFilePath = driverLocation;
} else {
// 4. Read SF_CLIENT_CONFIG_FILE_NAME if it is present in user home directory.
String userHomeFilePath =
Paths.get(systemGetProperty("user.home"), SF_CLIENT_CONFIG_FILE_NAME).toString();
if (Files.exists(Paths.get(userHomeFilePath))) {
logger.debug("Using config file specified from home directory: {}", userHomeFilePath);
logger.info("Using config file specified from home directory: {}", userHomeFilePath);
derivedConfigFilePath = userHomeFilePath;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/snowflake/client/core/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class FileUtil {
Arrays.asList(PosixFilePermission.GROUP_READ, PosixFilePermission.OTHERS_READ);

public static void logFileUsage(Path filePath, String context, boolean logReadAccess) {
logger.debug("{}Accessing file: {}", getContextStr(context), filePath);
logger.info("{}Accessing file: {}", getContextStr(context), filePath);
logWarnWhenAccessibleByOthers(filePath, context, logReadAccess);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/snowflake/client/core/SFBaseSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public HttpClientSettingsKey getHttpClientKey() throws SnowflakeSQLException {

private void logHttpClientInitInfo(HttpClientSettingsKey key) {
if (key.usesProxy()) {
logger.debug(
logger.info(
"Driver OCSP mode: {}, gzip disabled: {}, proxy protocol: {},"
+ " proxy host: {}, proxy port: {}, non proxy hosts: {}, proxy user: {}, proxy password is {}",
key.getOcspMode(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public void download(
EncryptionProvider.decrypt(localFile, key, iv, this.encMat);
stopwatch.stop();
long decryptMillis = stopwatch.elapsedMillis();
logger.debug(
logger.info(
"Azure file {} downloaded to {}. It took {} ms (download: {} ms, decryption: {} ms) with {} retries",
remoteStorageLocation,
localFile.getAbsolutePath(),
Expand All @@ -387,7 +387,7 @@ public void download(
throw ex;
}
} else {
logger.debug(
logger.info(
"Azure file {} downloaded to {}. It took {} ms with {} retries",
remoteStorageLocation,
localFile.getAbsolutePath(),
Expand Down Expand Up @@ -472,7 +472,7 @@ public InputStream downloadToStream(
InputStream is = EncryptionProvider.decryptStream(stream, key, iv, encMat);
stopwatch.stop();
long decryptMillis = stopwatch.elapsedMillis();
logger.debug(
logger.info(
"Azure file {} downloaded to input stream. It took {} ms "
+ "(download: {} ms, decryption: {} ms) with {} retries",
stageFilePath,
Expand All @@ -488,7 +488,7 @@ public InputStream downloadToStream(
}

} else {
logger.debug(
logger.info(
"Azure file {} downloaded to input stream. Download took {} ms with {} retries",
stageFilePath,
downloadMillis,
Expand Down Expand Up @@ -544,7 +544,7 @@ public void upload(
String presignedUrl,
String queryId)
throws SnowflakeSQLException {
logger.debug(
logger.info(
StorageHelper.getStartUploadLog(
"Azure", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName));
final List<FileInputStream> toClose = new ArrayList<>();
Expand Down Expand Up @@ -589,13 +589,13 @@ public void upload(
stopwatch.stop();

if (uploadFromStream) {
logger.debug(
logger.info(
"Uploaded data from input stream to Azure location: {}. It took {} ms with {} retries",
remoteStorageLocation,
stopwatch.elapsedMillis(),
retryCount);
} else {
logger.debug(
logger.info(
"Uploaded file {} to Azure location: {}. It took {} ms with {} retries",
srcFile.getAbsolutePath(),
remoteStorageLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public void download(
EncryptionProvider.decrypt(localFile, key, iv, this.encMat);
stopwatch.stop();
long decryptMillis = stopwatch.elapsedMillis();
logger.debug(
logger.info(
"GCS file {} downloaded to {}. It took {} ms (download: {} ms, decryption: {} ms) with {} retries",
stageFilePath,
localFile.getAbsolutePath(),
Expand All @@ -406,7 +406,7 @@ public void download(
"Cannot decrypt file");
}
} else {
logger.debug(
logger.info(
"GCS file {} downloaded to {}. It took {} ms with {} retries",
stageFilePath,
localFile.getAbsolutePath(),
Expand Down Expand Up @@ -565,7 +565,7 @@ public InputStream downloadToStream(
inputStream = EncryptionProvider.decryptStream(inputStream, key, iv, this.encMat);
stopwatch.stop();
long decryptMillis = stopwatch.elapsedMillis();
logger.debug(
logger.info(
"GCS file {} downloaded to stream. It took {} ms (download: {} ms, decryption: {} ms) with {} retries",
stageFilePath,
downloadMillis + decryptMillis,
Expand All @@ -584,7 +584,7 @@ public InputStream downloadToStream(
"Cannot decrypt file");
}
} else {
logger.debug(
logger.info(
"GCS file {} downloaded to stream. Download took {} ms with {} retries",
stageFilePath,
downloadMillis,
Expand Down Expand Up @@ -640,7 +640,7 @@ public void uploadWithPresignedUrlWithoutConnection(
String presignedUrl,
String queryId)
throws SnowflakeSQLException {
logger.debug(
logger.info(
StorageHelper.getStartUploadLog(
"GCS", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName));
final List<FileInputStream> toClose = new ArrayList<>();
Expand Down Expand Up @@ -690,12 +690,12 @@ public void uploadWithPresignedUrlWithoutConnection(
stopwatch.stop();

if (uploadFromStream) {
logger.debug(
logger.info(
"Uploaded data from input stream to GCS location: {}. It took {} ms",
remoteStorageLocation,
stopwatch.elapsedMillis());
} else {
logger.debug(
logger.info(
"Uploaded file {} to GCS location: {}. It took {} ms",
srcFile.getAbsolutePath(),
remoteStorageLocation,
Expand Down Expand Up @@ -742,7 +742,7 @@ public void upload(
String presignedUrl,
String queryId)
throws SnowflakeSQLException {
logger.debug(
logger.info(
StorageHelper.getStartUploadLog(
"GCS", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName));
final List<FileInputStream> toClose = new ArrayList<>();
Expand Down Expand Up @@ -780,12 +780,12 @@ public void upload(
stopwatch.stop();
logger.debug("Upload successful", false);
if (uploadFromStream) {
logger.debug(
logger.info(
"Uploaded data from input stream to GCS location: {}. It took {} ms",
remoteStorageLocation,
stopwatch.elapsedMillis());
} else {
logger.debug(
logger.info(
"Uploaded file {} to GCS location: {}. It took {} ms",
srcFile.getAbsolutePath(),
remoteStorageLocation,
Expand Down Expand Up @@ -817,12 +817,12 @@ public void upload(
stopwatch.stop();
logger.debug("Upload successful", false);
if (uploadFromStream) {
logger.debug(
logger.info(
"Uploaded data from input stream to GCS location: {}. It took {} ms",
remoteStorageLocation,
stopwatch.elapsedMillis());
} else {
logger.debug(
logger.info(
"Uploaded file {} to GCS location: {}. It took {} ms",
srcFile.getAbsolutePath(),
remoteStorageLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public ExecutorService newExecutor() {
EncryptionProvider.decrypt(localFile, key, iv, this.encMat);
stopwatch.stop();
long decryptMillis = stopwatch.elapsedMillis();
logger.debug(
logger.info(
"S3 file {} downloaded to {}. It took {} ms (download: {} ms, decryption: {} ms) with {} retries",
stageFilePath,
localFile.getAbsolutePath(),
Expand All @@ -420,7 +420,7 @@ public ExecutorService newExecutor() {
throw ex;
}
} else {
logger.debug(
logger.info(
"S3 file {} downloaded to {}. It took {} ms with {} retries",
stageFilePath,
localFile.getAbsolutePath(),
Expand Down Expand Up @@ -574,7 +574,7 @@ public void upload(
String presignedUrl,
String queryId)
throws SnowflakeSQLException {
logger.debug(
logger.info(
StorageHelper.getStartUploadLog(
"S3", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName));

Expand Down Expand Up @@ -649,13 +649,13 @@ public ExecutorService newExecutor() {
}

if (uploadFromStream) {
logger.debug(
logger.info(
"Uploaded data from input stream to S3 location: {}. It took {} ms with {} retries",
destFileName,
uploadMillis,
retryCount);
} else {
logger.debug(
logger.info(
"Uploaded file {} to S3 location: {}. It took {} ms with {} retries",
srcFile.getAbsolutePath(),
destFileName,
Expand Down

0 comments on commit 60a139d

Please sign in to comment.