From d2f94f408354ddd7255af31b01373f4c86c0a1fb Mon Sep 17 00:00:00 2001 From: Louie Farol Date: Fri, 6 Dec 2024 16:53:42 -0800 Subject: [PATCH] Revert logger name --- .../Core/Authenticator/IAuthenticator.cs | 8 +-- .../Authenticator/KeyPairAuthenticator.cs | 1 - Snowflake.Data/Core/ChunkDownloaderFactory.cs | 2 +- Snowflake.Data/Core/ChunkParserFactory.cs | 2 +- Snowflake.Data/Core/FastParser.cs | 8 +-- .../Core/FileTransfer/EncryptionProvider.cs | 6 +- .../Core/FileTransfer/SFFileTransferAgent.cs | 58 +++++++++---------- .../FileTransfer/StorageClient/SFGCSClient.cs | 16 ++--- .../FileTransfer/StorageClient/SFS3Client.cs | 10 ++-- .../StorageClient/SFSnowflakeAzureClient.cs | 4 +- Snowflake.Data/Core/HttpUtil.cs | 6 +- Snowflake.Data/Core/RestRequester.cs | 10 ++-- Snowflake.Data/Core/SFBindUploader.cs | 6 +- .../Core/SFBlockingChunkDownloaderV3.cs | 10 ++-- .../Core/SFMultiStatementsResultSet.cs | 4 +- Snowflake.Data/Core/SFResultSet.cs | 4 +- Snowflake.Data/Core/SFResultSetMetaData.cs | 4 +- Snowflake.Data/Core/SFStatement.cs | 42 +++++++------- 18 files changed, 100 insertions(+), 101 deletions(-) diff --git a/Snowflake.Data/Core/Authenticator/IAuthenticator.cs b/Snowflake.Data/Core/Authenticator/IAuthenticator.cs index 40a98e761..7a41a8335 100644 --- a/Snowflake.Data/Core/Authenticator/IAuthenticator.cs +++ b/Snowflake.Data/Core/Authenticator/IAuthenticator.cs @@ -134,7 +134,7 @@ private SFRestRequest BuildLoginRequest() /// internal class AuthenticatorFactory { - private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); + private static readonly SFLogger logger = SFLoggerFactory.GetLogger(); /// /// Generate the authenticator given the session /// @@ -164,7 +164,7 @@ internal static IAuthenticator GetAuthenticator(SFSession session) var error = new SnowflakeDbException( SFError.INVALID_CONNECTION_STRING, new object[] { invalidStringDetail }); - s_logger.Error(error.Message, error); + logger.Error(error.Message, error); throw error; } @@ -181,7 +181,7 @@ internal static IAuthenticator GetAuthenticator(SFSession session) var error = new SnowflakeDbException( SFError.INVALID_CONNECTION_STRING, new object[] { invalidStringDetail }); - s_logger.Error(error.Message, error); + logger.Error(error.Message, error); throw error; } @@ -192,7 +192,7 @@ internal static IAuthenticator GetAuthenticator(SFSession session) { return new OktaAuthenticator(session, type); } - s_logger.Error($"Unknown authenticator {type}"); + logger.Error($"Unknown authenticator {type}"); throw new SnowflakeDbException(SFError.UNKNOWN_AUTHENTICATOR, type); } } diff --git a/Snowflake.Data/Core/Authenticator/KeyPairAuthenticator.cs b/Snowflake.Data/Core/Authenticator/KeyPairAuthenticator.cs index 2a8522dbc..7d86d02c9 100644 --- a/Snowflake.Data/Core/Authenticator/KeyPairAuthenticator.cs +++ b/Snowflake.Data/Core/Authenticator/KeyPairAuthenticator.cs @@ -19,7 +19,6 @@ using Org.BouncyCastle.X509; using System.Security.Claims; using Microsoft.IdentityModel.Tokens; - namespace Snowflake.Data.Core.Authenticator { /// diff --git a/Snowflake.Data/Core/ChunkDownloaderFactory.cs b/Snowflake.Data/Core/ChunkDownloaderFactory.cs index 48f888a4c..553e67d2d 100755 --- a/Snowflake.Data/Core/ChunkDownloaderFactory.cs +++ b/Snowflake.Data/Core/ChunkDownloaderFactory.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2012-2019 Snowflake Computing Inc. All rights reserved. */ diff --git a/Snowflake.Data/Core/ChunkParserFactory.cs b/Snowflake.Data/Core/ChunkParserFactory.cs index be4435ffa..87d3a5f33 100755 --- a/Snowflake.Data/Core/ChunkParserFactory.cs +++ b/Snowflake.Data/Core/ChunkParserFactory.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2012-2019 Snowflake Computing Inc. All rights reserved. */ diff --git a/Snowflake.Data/Core/FastParser.cs b/Snowflake.Data/Core/FastParser.cs index 1f5b997b3..632876269 100644 --- a/Snowflake.Data/Core/FastParser.cs +++ b/Snowflake.Data/Core/FastParser.cs @@ -6,14 +6,14 @@ namespace Snowflake.Data.Core { public class FastParser { - private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); + private static readonly SFLogger Logger = SFLoggerFactory.GetLogger(); public static Int64 FastParseInt64(byte[] s, int offset, int len) { if (s == null) { Exception ex = new SnowflakeDbException(SFError.INTERNAL_ERROR, $"Cannot parse a null buffer"); - s_logger.Error("A null buffer was passed to FastParseInt64", ex); + Logger.Error("A null buffer was passed to FastParseInt64", ex); throw ex; } @@ -54,7 +54,7 @@ public static Int32 FastParseInt32(byte[] s, int offset, int len) if (s == null) { Exception ex = new SnowflakeDbException(SFError.INTERNAL_ERROR, $"Cannot parse a null buffer"); - s_logger.Error("A null buffer was passed to FastParseInt32", ex); + Logger.Error("A null buffer was passed to FastParseInt32", ex); throw ex; } @@ -95,7 +95,7 @@ public static decimal FastParseDecimal(byte[] s, int offset, int len) if (s == null) { Exception ex = new SnowflakeDbException(SFError.INTERNAL_ERROR, $"Cannot parse a null buffer"); - s_logger.Error("A null buffer was passed to FastParseDecimal", ex); + Logger.Error("A null buffer was passed to FastParseDecimal", ex); throw ex; } diff --git a/Snowflake.Data/Core/FileTransfer/EncryptionProvider.cs b/Snowflake.Data/Core/FileTransfer/EncryptionProvider.cs index 6f02f8943..b625f80d3 100644 --- a/Snowflake.Data/Core/FileTransfer/EncryptionProvider.cs +++ b/Snowflake.Data/Core/FileTransfer/EncryptionProvider.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2023 Snowflake Computing Inc. All rights reserved. */ @@ -22,7 +22,7 @@ class EncryptionProvider /// /// The logger. /// - private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); + private static readonly SFLogger Logger = SFLoggerFactory.GetLogger(); /// /// Encrypt data and write to the outStream. @@ -60,7 +60,7 @@ public static StreamPair EncryptStream( { byte[] decodedMasterKey = Convert.FromBase64String(encryptionMaterial.queryStageMasterKey); int masterKeySize = decodedMasterKey.Length; - s_logger.Debug($"Master key size : {masterKeySize}"); + Logger.Debug($"Master key size : {masterKeySize}"); // Generate file key byte[] ivData = new byte[blockSize]; diff --git a/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs b/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs index 6c6cbc6fd..1ee8557b6 100644 --- a/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs +++ b/Snowflake.Data/Core/FileTransfer/SFFileTransferAgent.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2021 Snowflake Computing Inc. All rights reserved. */ @@ -60,7 +60,7 @@ class SFFileTransferAgent /// /// The logger. /// - private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); + private static readonly SFLogger Logger = SFLoggerFactory.GetLogger(); /// /// Auto-detect keyword for source compression type auto detection. @@ -230,7 +230,7 @@ public void execute() } catch (Exception e) { - s_logger.Error("Error while transferring file(s): " + e.Message); + Logger.Error("Error while transferring file(s): " + e.Message); if (e is SnowflakeDbException snowflakeException) { if (snowflakeException.QueryId == null) @@ -346,19 +346,19 @@ private void upload() //For each file, using the remote client if (0 < LargeFilesMetas.Count) { - s_logger.Debug("Start uploading large files"); + Logger.Debug("Start uploading large files"); foreach (SFFileMetadata fileMetadata in LargeFilesMetas) { UploadFilesInSequential(fileMetadata); } - s_logger.Debug("End uploading large files"); + Logger.Debug("End uploading large files"); } if (0 < SmallFilesMetas.Count) { - s_logger.Debug("Start uploading small files"); + Logger.Debug("Start uploading small files"); UploadFilesInParallel(SmallFilesMetas, TransferMetadata.parallel); - s_logger.Debug("End uploading small files"); + Logger.Debug("End uploading small files"); } } @@ -372,19 +372,19 @@ private async Task uploadAsync(CancellationToken cancellationToken) //For each file, using the remote client if (0 < LargeFilesMetas.Count) { - s_logger.Debug("Start uploading large files"); + Logger.Debug("Start uploading large files"); foreach (SFFileMetadata fileMetadata in LargeFilesMetas) { await UploadFilesInSequentialAsync(fileMetadata, cancellationToken).ConfigureAwait(false); } - s_logger.Debug("End uploading large files"); + Logger.Debug("End uploading large files"); } if (0 < SmallFilesMetas.Count) { - s_logger.Debug("Start uploading small files"); + Logger.Debug("Start uploading small files"); await UploadFilesInParallelAsync(SmallFilesMetas, TransferMetadata.parallel, cancellationToken).ConfigureAwait(false); - s_logger.Debug("End uploading small files"); + Logger.Debug("End uploading small files"); } } @@ -399,18 +399,18 @@ private void download() //For each file, using the remote client if (0 < LargeFilesMetas.Count) { - s_logger.Debug("Start uploading large files"); + Logger.Debug("Start uploading large files"); foreach (SFFileMetadata fileMetadata in LargeFilesMetas) { DownloadFilesInSequential(fileMetadata); } - s_logger.Debug("End uploading large files"); + Logger.Debug("End uploading large files"); } if (0 < SmallFilesMetas.Count) { - s_logger.Debug("Start uploading small files"); + Logger.Debug("Start uploading small files"); DownloadFilesInParallel(SmallFilesMetas, TransferMetadata.parallel); - s_logger.Debug("End uploading small files"); + Logger.Debug("End uploading small files"); } } @@ -424,18 +424,18 @@ private async Task downloadAsync(CancellationToken cancellationToken) //For each file, using the remote client if (0 < LargeFilesMetas.Count) { - s_logger.Debug("Start uploading large files"); + Logger.Debug("Start uploading large files"); foreach (SFFileMetadata fileMetadata in LargeFilesMetas) { await DownloadFilesInSequentialAsync(fileMetadata, cancellationToken).ConfigureAwait(false); } - s_logger.Debug("End uploading large files"); + Logger.Debug("End uploading large files"); } if (0 < SmallFilesMetas.Count) { - s_logger.Debug("Start uploading small files"); + Logger.Debug("Start uploading small files"); await DownloadFilesInParallelAsync(SmallFilesMetas, TransferMetadata.parallel, cancellationToken).ConfigureAwait(false); - s_logger.Debug("End uploading small files"); + Logger.Debug("End uploading small files"); } } @@ -574,7 +574,7 @@ private void initFileMetadata( // Auto-detect source compression type // Will return NONE if no matching type is found compressionType = SFFileCompressionTypes.GuessCompressionType(file); - s_logger.Debug($"File compression detected as {compressionType.Name} for: {file}"); + Logger.Debug($"File compression detected as {compressionType.Name} for: {file}"); } else { @@ -716,7 +716,7 @@ private int GetFileTransferMaxBytesInMemory() } catch (Exception) { - s_logger.Warn("Default for FILE_TRANSFER_MEMORY_THRESHOLD used due to invalid session value."); + Logger.Warn("Default for FILE_TRANSFER_MEMORY_THRESHOLD used due to invalid session value."); return FileTransferConfiguration.DefaultMaxBytesInMemory; } } @@ -782,12 +782,12 @@ private List expandFileNames(string location) } } - if (s_logger.IsDebugEnabled()) + if (Logger.IsDebugEnabled()) { - s_logger.Debug("Expand " + location + " into: "); + Logger.Debug("Expand " + location + " into: "); foreach (var filepath in filePaths) { - s_logger.Debug("\t" + filepath ); + Logger.Debug("\t" + filepath ); } } @@ -901,7 +901,7 @@ private void compressFileWithGzip(SFFileMetadata fileMetadata) } } - s_logger.Debug($"Compressed {fileToCompress.Name} to {fileMetadata.realSrcFilePath}"); + Logger.Debug($"Compressed {fileToCompress.Name} to {fileMetadata.realSrcFilePath}"); FileInfo destInfo = new FileInfo(fileMetadata.realSrcFilePath); fileMetadata.destFileSize = destInfo.Length; } @@ -1235,7 +1235,7 @@ private SFFileMetadata UploadSingleFile( } catch (Exception ex) { - s_logger.Debug("Unhandled exception while uploading file.", ex); + Logger.Debug("Unhandled exception while uploading file.", ex); throw; } finally @@ -1284,7 +1284,7 @@ private async Task UploadSingleFileAsync( } catch (Exception ex) { - s_logger.Error("UploadSingleFileAsync encountered an error: " + ex.Message); + Logger.Error("UploadSingleFileAsync encountered an error: " + ex.Message); throw; } finally @@ -1322,7 +1322,7 @@ private SFFileMetadata DownloadSingleFile( } catch (Exception ex) { - s_logger.Error("DownloadSingleFile encountered an error: " + ex.Message); + Logger.Error("DownloadSingleFile encountered an error: " + ex.Message); throw; } finally @@ -1360,7 +1360,7 @@ private async Task DownloadSingleFileAsync( } catch (Exception ex) { - s_logger.Error("DownloadSingleFileAsync encountered an error: " + ex.Message); + Logger.Error("DownloadSingleFileAsync encountered an error: " + ex.Message); throw; } finally diff --git a/Snowflake.Data/Core/FileTransfer/StorageClient/SFGCSClient.cs b/Snowflake.Data/Core/FileTransfer/StorageClient/SFGCSClient.cs index d0a9f1ac6..1a86b15a9 100644 --- a/Snowflake.Data/Core/FileTransfer/StorageClient/SFGCSClient.cs +++ b/Snowflake.Data/Core/FileTransfer/StorageClient/SFGCSClient.cs @@ -42,7 +42,7 @@ class SFGCSClient : ISFRemoteStorageClient /// /// The logger. /// - private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); + private static readonly SFLogger Logger = SFLoggerFactory.GetLogger(); /// /// The storage client. @@ -62,11 +62,11 @@ class SFGCSClient : ISFRemoteStorageClient /// The command stage info. public SFGCSClient(PutGetStageInfo stageInfo) { - s_logger.Debug("Setting up a new GCS client "); + Logger.Debug("Setting up a new GCS client "); if (stageInfo.stageCredentials.TryGetValue(GCS_ACCESS_TOKEN, out string accessToken)) { - s_logger.Debug("Constructing client using access token"); + Logger.Debug("Constructing client using access token"); AccessToken = accessToken; GoogleCredential creds = GoogleCredential.FromAccessToken(accessToken, null); var storageClientBuilder = new StorageClientBuilder @@ -78,7 +78,7 @@ public SFGCSClient(PutGetStageInfo stageInfo) } else { - s_logger.Info("No access token received from GS, constructing anonymous client with no encryption support"); + Logger.Info("No access token received from GS, constructing anonymous client with no encryption support"); var storageClientBuilder = new StorageClientBuilder { UnauthenticatedAccess = true @@ -475,7 +475,7 @@ private void HandleDownloadResponse(HttpWebResponse response, SFFileMetadata fil /// File Metadata private SFFileMetadata HandleFileHeaderErrForPresignedUrls(WebException ex, SFFileMetadata fileMetadata) { - s_logger.Error("Failed to get file header for presigned url: " + ex.Message); + Logger.Error("Failed to get file header for presigned url: " + ex.Message); HttpWebResponse response = (HttpWebResponse)ex.Response; if (response.StatusCode == HttpStatusCode.Unauthorized || @@ -501,7 +501,7 @@ private SFFileMetadata HandleFileHeaderErrForPresignedUrls(WebException ex, SFFi /// File Metadata private SFFileMetadata HandleFileHeaderErrForGeneratedUrls(WebException ex, SFFileMetadata fileMetadata) { - s_logger.Error("Failed to get file header for non-presigned url: " + ex.Message); + Logger.Error("Failed to get file header for non-presigned url: " + ex.Message); HttpWebResponse response = (HttpWebResponse)ex.Response; if (response.StatusCode == HttpStatusCode.Unauthorized) @@ -536,7 +536,7 @@ private SFFileMetadata HandleFileHeaderErrForGeneratedUrls(WebException ex, SFFi /// File Metadata private SFFileMetadata HandleUploadFileErr(WebException ex, SFFileMetadata fileMetadata) { - s_logger.Error("Failed to upload file: " + ex.Message); + Logger.Error("Failed to upload file: " + ex.Message); fileMetadata.lastError = ex; @@ -570,7 +570,7 @@ private SFFileMetadata HandleUploadFileErr(WebException ex, SFFileMetadata fileM /// File Metadata private SFFileMetadata HandleDownloadFileErr(WebException ex, SFFileMetadata fileMetadata) { - s_logger.Error("Failed to download file: " + ex.Message); + Logger.Error("Failed to download file: " + ex.Message); fileMetadata.lastError = ex; diff --git a/Snowflake.Data/Core/FileTransfer/StorageClient/SFS3Client.cs b/Snowflake.Data/Core/FileTransfer/StorageClient/SFS3Client.cs index 025dbac15..524dc23c1 100644 --- a/Snowflake.Data/Core/FileTransfer/StorageClient/SFS3Client.cs +++ b/Snowflake.Data/Core/FileTransfer/StorageClient/SFS3Client.cs @@ -72,7 +72,7 @@ internal class S3Metadata /// /// The logger. /// - private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); + private static readonly SFLogger Logger = SFLoggerFactory.GetLogger(); /// /// The underlying S3 client. @@ -89,7 +89,7 @@ public SFS3Client( int parallel, ProxyCredentials proxyCredentials) { - s_logger.Debug("Setting up a new AWS client "); + Logger.Debug("Setting up a new AWS client "); // Get the key id and secret key from the response stageInfo.stageCredentials.TryGetValue(AWS_KEY_ID, out string awsAccessKeyId); @@ -537,7 +537,7 @@ private GetObjectRequest GetGetObjectRequest(ref AmazonS3Client client, SFFileMe /// The file metadata. private void HandleFileHeaderErr(Exception ex, SFFileMetadata fileMetadata) { - s_logger.Error("Failed to get file header: " + ex.Message); + Logger.Error("Failed to get file header: " + ex.Message); switch (ex) { @@ -569,7 +569,7 @@ private void HandleFileHeaderErr(Exception ex, SFFileMetadata fileMetadata) /// The file metadata. private void HandleUploadFileErr(Exception ex, SFFileMetadata fileMetadata) { - s_logger.Error("Failed to upload file: " + ex.Message); + Logger.Error("Failed to upload file: " + ex.Message); switch (ex) { @@ -599,7 +599,7 @@ private void HandleUploadFileErr(Exception ex, SFFileMetadata fileMetadata) /// The file metadata. private void HandleDownloadFileErr(Exception ex, SFFileMetadata fileMetadata) { - s_logger.Error("Failed to download file: " + ex.Message); + Logger.Error("Failed to download file: " + ex.Message); switch (ex) { diff --git a/Snowflake.Data/Core/FileTransfer/StorageClient/SFSnowflakeAzureClient.cs b/Snowflake.Data/Core/FileTransfer/StorageClient/SFSnowflakeAzureClient.cs index 1175ff3cd..d13dc01b9 100644 --- a/Snowflake.Data/Core/FileTransfer/StorageClient/SFSnowflakeAzureClient.cs +++ b/Snowflake.Data/Core/FileTransfer/StorageClient/SFSnowflakeAzureClient.cs @@ -31,7 +31,7 @@ class SFSnowflakeAzureClient : ISFRemoteStorageClient /// /// The logger. /// - private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); + private static readonly SFLogger Logger = SFLoggerFactory.GetLogger(); /// /// The cloud blob client to use to upload and download data on Azure. @@ -44,7 +44,7 @@ class SFSnowflakeAzureClient : ISFRemoteStorageClient /// The command stage info. public SFSnowflakeAzureClient(PutGetStageInfo stageInfo) { - s_logger.Debug("Setting up a new Azure client "); + Logger.Debug("Setting up a new Azure client "); // Get the Azure SAS token and create the client if (stageInfo.stageCredentials.TryGetValue(AZURE_SAS_TOKEN, out string sasToken)) diff --git a/Snowflake.Data/Core/HttpUtil.cs b/Snowflake.Data/Core/HttpUtil.cs index d352dd0d3..750729885 100644 --- a/Snowflake.Data/Core/HttpUtil.cs +++ b/Snowflake.Data/Core/HttpUtil.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2012-2021 Snowflake Computing Inc. All rights reserved. */ @@ -77,7 +77,7 @@ public sealed class HttpUtil static internal readonly int MAX_BACKOFF = 16; private static readonly int s_baseBackOffTime = 1; private static readonly int s_exponentialFactor = 2; - private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); + private static readonly SFLogger logger = SFLoggerFactory.GetLogger(); private static readonly List s_supportedEndpointsForRetryPolicy = new List { @@ -114,7 +114,7 @@ private HttpClient RegisterNewHttpClientIfNecessary(HttpClientConfig config, Del string name = config.ConfKey; if (!_HttpClients.ContainsKey(name)) { - s_logger.Debug("Http client not registered. Adding."); + logger.Debug("Http client not registered. Adding."); var httpClient = new HttpClient( new RetryHandler(SetupCustomHttpHandler(config, customHandler), config.DisableRetry, config.ForceRetryOn404, config.MaxHttpRetries, config.IncludeRetryReason)) diff --git a/Snowflake.Data/Core/RestRequester.cs b/Snowflake.Data/Core/RestRequester.cs index a6dc8f8ec..4c2c7ee39 100644 --- a/Snowflake.Data/Core/RestRequester.cs +++ b/Snowflake.Data/Core/RestRequester.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2012-2019 Snowflake Computing Inc. All rights reserved. */ @@ -39,7 +39,7 @@ internal interface IMockRestRequester : IRestRequester internal class RestRequester : IRestRequester { - private static SFLogger s_logger = SFLoggerFactory.GetLogger(); + private static SFLogger logger = SFLoggerFactory.GetLogger(); protected HttpClient _HttpClient; @@ -113,18 +113,18 @@ protected virtual async Task SendAsync(HttpRequestMessage m HttpResponseMessage response = null; try { - s_logger.Debug($"Executing: {sid} {message.Method} {message.RequestUri} HTTP/{message.Version}"); + logger.Debug($"Executing: {sid} {message.Method} {message.RequestUri} HTTP/{message.Version}"); response = await _HttpClient .SendAsync(message, HttpCompletionOption.ResponseHeadersRead, linkedCts.Token) .ConfigureAwait(false); if (!response.IsSuccessStatusCode) { - s_logger.Error($"Failed Response: {sid} {message.Method} {message.RequestUri} StatusCode: {(int)response.StatusCode}, ReasonPhrase: '{response.ReasonPhrase}'"); + logger.Error($"Failed Response: {sid} {message.Method} {message.RequestUri} StatusCode: {(int)response.StatusCode}, ReasonPhrase: '{response.ReasonPhrase}'"); } else { - s_logger.Debug($"Succeeded Response: {sid} {message.Method} {message.RequestUri}"); + logger.Debug($"Succeeded Response: {sid} {message.Method} {message.RequestUri}"); } response.EnsureSuccessStatusCode(); diff --git a/Snowflake.Data/Core/SFBindUploader.cs b/Snowflake.Data/Core/SFBindUploader.cs index 00031ab2a..dfc98c1bf 100644 --- a/Snowflake.Data/Core/SFBindUploader.cs +++ b/Snowflake.Data/Core/SFBindUploader.cs @@ -35,7 +35,7 @@ class SFBindUploader private string requestId; - private SFLogger loggerPair = SFLoggerFactory.GetLogger(); + private SFLogger logger = SFLoggerFactory.GetLogger(); private string stagePath; @@ -309,7 +309,7 @@ private void CreateStage() catch (Exception e) { session.SetArrayBindStageThreshold(0); - loggerPair.Error("Failed to create temporary stage for array binds.", e); + logger.Error("Failed to create temporary stage for array binds.", e); throw; } } @@ -333,7 +333,7 @@ internal async Task CreateStageAsync(CancellationToken cancellationToken) catch (Exception e) { session.SetArrayBindStageThreshold(0); - loggerPair.Error("Failed to create temporary stage for array binds.", e); + logger.Error("Failed to create temporary stage for array binds.", e); throw; } } diff --git a/Snowflake.Data/Core/SFBlockingChunkDownloaderV3.cs b/Snowflake.Data/Core/SFBlockingChunkDownloaderV3.cs index d4f76ff44..955af16a4 100755 --- a/Snowflake.Data/Core/SFBlockingChunkDownloaderV3.cs +++ b/Snowflake.Data/Core/SFBlockingChunkDownloaderV3.cs @@ -22,7 +22,7 @@ namespace Snowflake.Data.Core { class SFBlockingChunkDownloaderV3 : IChunkDownloader { - static private SFLogger s_logger = SFLoggerFactory.GetLogger(); + static private SFLogger logger = SFLoggerFactory.GetLogger(); private List chunkDatas = new List(); @@ -99,7 +99,7 @@ private int GetPrefetchThreads(SFBaseResultSet resultSet) public async Task GetNextChunkAsync() { - s_logger.Info($"NextChunkToConsume: {nextChunkToConsumeIndex}, NextChunkToDownload: {nextChunkToDownloadIndex}"); + logger.Info($"NextChunkToConsume: {nextChunkToConsumeIndex}, NextChunkToDownload: {nextChunkToDownloadIndex}"); if (nextChunkToConsumeIndex < chunkInfos.Count) { Task chunk = taskQueues[nextChunkToConsumeIndex % prefetchSlot]; @@ -192,7 +192,7 @@ private async Task DownloadChunkAsync(DownloadContextV3 downloa { if ((maxRetry <= 0) || (retryCount < maxRetry)) { - s_logger.Debug($"Retry {retryCount}/{maxRetry} of parse stream to chunk error: " + e.Message); + logger.Debug($"Retry {retryCount}/{maxRetry} of parse stream to chunk error: " + e.Message); retry = true; // reset the chunk before retry in case there could be garbage // data left from last attempt @@ -209,13 +209,13 @@ private async Task DownloadChunkAsync(DownloadContextV3 downloa else { //parse error - s_logger.Error("Failed retries of parse stream to chunk error: " + e.Message); + logger.Error("Failed retries of parse stream to chunk error: " + e.Message); throw new Exception("Parse stream to chunk error: " + e.Message); } } } } while (retry); - s_logger.Info($"Succeed downloading chunk #{chunk.ChunkIndex}"); + logger.Info($"Succeed downloading chunk #{chunk.ChunkIndex}"); return chunk; } diff --git a/Snowflake.Data/Core/SFMultiStatementsResultSet.cs b/Snowflake.Data/Core/SFMultiStatementsResultSet.cs index 5d1e67f65..18eb4f650 100644 --- a/Snowflake.Data/Core/SFMultiStatementsResultSet.cs +++ b/Snowflake.Data/Core/SFMultiStatementsResultSet.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2022 Snowflake Computing Inc. All rights reserved. */ @@ -15,7 +15,7 @@ class SFMultiStatementsResultSet : SFBaseResultSet { internal override ResultFormat ResultFormat => curResultSet.ResultFormat; - private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); + private static readonly SFLogger Logger = SFLoggerFactory.GetLogger(); private string[] resultIds; diff --git a/Snowflake.Data/Core/SFResultSet.cs b/Snowflake.Data/Core/SFResultSet.cs index 96c349de3..e81db8c14 100755 --- a/Snowflake.Data/Core/SFResultSet.cs +++ b/Snowflake.Data/Core/SFResultSet.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2012-2019 Snowflake Computing Inc. All rights reserved. */ @@ -100,7 +100,7 @@ public SFResultSet(PutGetResponseData responseData, SFStatement sfStatement, Can internal void ResetChunkInfo(BaseResultChunk nextChunk) { - s_logger.Debug($"Received chunk #{nextChunk.ChunkIndex + 1} of {_totalChunkCount}"); + s_logger.Debug($"Received chunk #{nextChunk.ChunkIndex + 1} of {_totalChunkCount}"); _currentChunk.RowSet = null; _currentChunk = nextChunk; } diff --git a/Snowflake.Data/Core/SFResultSetMetaData.cs b/Snowflake.Data/Core/SFResultSetMetaData.cs index 3bc847ac3..bb5f2e819 100755 --- a/Snowflake.Data/Core/SFResultSetMetaData.cs +++ b/Snowflake.Data/Core/SFResultSetMetaData.cs @@ -12,7 +12,7 @@ namespace Snowflake.Data.Core { class SFResultSetMetaData { - static private readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); + static private readonly SFLogger logger = SFLoggerFactory.GetLogger(); private int columnCount; @@ -92,7 +92,7 @@ internal int GetColumnIndexByName(string targetColumnName) { if (String.Compare(rowType.name, targetColumnName, false) == 0 ) { - s_logger.Info($"Found column name {targetColumnName} under index {indexCounter}"); + logger.Info($"Found column name {targetColumnName} under index {indexCounter}"); columnNameToIndexCache[targetColumnName] = indexCounter; return indexCounter; } diff --git a/Snowflake.Data/Core/SFStatement.cs b/Snowflake.Data/Core/SFStatement.cs index 90ad6e1d9..7dac1c600 100644 --- a/Snowflake.Data/Core/SFStatement.cs +++ b/Snowflake.Data/Core/SFStatement.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2012-2019 Snowflake Computing Inc. All rights reserved. */ @@ -97,7 +97,7 @@ internal static bool IsAnError(QueryStatus status) class SFStatement { - static private SFLogger s_logger = SFLoggerFactory.GetLogger(); + static private SFLogger logger = SFLoggerFactory.GetLogger(); internal SFSession SfSession { get; set; } @@ -168,7 +168,7 @@ private void AssignQueryRequestId() if (_requestId != null) { - s_logger.Info("Another query is running."); + logger.Info("Another query is running."); throw new SnowflakeDbException(SFError.STATEMENT_ALREADY_RUNNING_QUERY); } @@ -340,7 +340,7 @@ private void registerQueryCancellationCallback(int timeout, CancellationToken ex catch (Exception ex) { // Prevent an unhandled exception from being thrown - s_logger.Error("Unable to cancel query.", ex); + logger.Error("Unable to cancel query.", ex); } }); } @@ -386,7 +386,7 @@ internal async Task ExecuteAsync(int timeout, string sql, Dicti } catch (Exception e) { - s_logger.Warn("Exception encountered trying to upload binds to stage. Attaching binds in payload instead. Exception: " + e.Message); + logger.Warn("Exception encountered trying to upload binds to stage. Attaching binds in payload instead. Exception: " + e.Message); } finally { @@ -424,7 +424,7 @@ internal async Task ExecuteAsync(int timeout, string sql, Dicti if (SessionExpired(response)) { - s_logger.Info("Ping pong request failed with session expired, trying to renew the session."); + logger.Info("Ping pong request failed with session expired, trying to renew the session."); await SfSession.renewSessionAsync(cancellationToken).ConfigureAwait(false); } else @@ -438,7 +438,7 @@ internal async Task ExecuteAsync(int timeout, string sql, Dicti } catch { - s_logger.Error("Query execution failed."); + logger.Error("Query execution failed."); throw; } finally @@ -484,7 +484,7 @@ private SFBaseResultSet ExecuteSqlWithPutGet(int timeout, string sql, string tri bindings, describeOnly); - s_logger.Debug("PUT/GET queryId: " + (response.data != null ? response.data.queryId : "Unknown")); + logger.Debug("PUT/GET queryId: " + (response.data != null ? response.data.queryId : "Unknown")); SFFileTransferAgent fileTransferAgent = new SFFileTransferAgent(trimmedSql, SfSession, response.data, CancellationToken.None); @@ -500,13 +500,13 @@ private SFBaseResultSet ExecuteSqlWithPutGet(int timeout, string sql, string tri } catch (SnowflakeDbException ex) { - s_logger.Error($"Query execution failed, QueryId: {ex.QueryId??"unavailable"}", ex); + logger.Error($"Query execution failed, QueryId: {ex.QueryId??"unavailable"}", ex); _lastQueryId = ex.QueryId ?? _lastQueryId; throw; } catch (Exception ex) { - s_logger.Error("Query execution failed.", ex); + logger.Error("Query execution failed.", ex); throw new SnowflakeDbException(ex, SFError.INTERNAL_ERROR); } } @@ -538,7 +538,7 @@ private SFBaseResultSet ExecuteSqlOtherThanPutGet(int timeout, string sql, Dicti } catch (Exception e) { - s_logger.Warn("Exception encountered trying to upload binds to stage. Attaching binds in payload instead. Exception: " + e.Message); + logger.Warn("Exception encountered trying to upload binds to stage. Attaching binds in payload instead. Exception: " + e.Message); } finally { @@ -558,7 +558,7 @@ private SFBaseResultSet ExecuteSqlOtherThanPutGet(int timeout, string sql, Dicti } catch (Exception ex) { - s_logger.Error("Query execution failed.", ex); + logger.Error("Query execution failed.", ex); if (ex is SnowflakeDbException snowflakeDbException) { _lastQueryId = snowflakeDbException.QueryId ?? _lastQueryId; @@ -624,11 +624,11 @@ internal void Cancel() if (response.success) { - s_logger.Info("Query cancellation succeed"); + logger.Info("Query cancellation succeed"); } else { - s_logger.Warn("Query cancellation failed."); + logger.Warn("Query cancellation failed."); } CleanUpCancellationTokenSources(); } @@ -685,7 +685,7 @@ internal T ExecuteHelper( if (SessionExpired(response)) { - s_logger.Info("Ping pong request failed with session expired, trying to renew the session."); + logger.Info("Ping pong request failed with session expired, trying to renew the session."); SfSession.renewSession(); } else @@ -709,7 +709,7 @@ internal T ExecuteHelper( } catch (Exception ex) { - s_logger.Error("Query execution failed.", ex); + logger.Error("Query execution failed.", ex); throw; } finally @@ -772,7 +772,7 @@ internal async Task ExecuteAsyncHelper( if (SessionExpired(response)) { - s_logger.Info("Ping pong request failed with session expired, trying to renew the session."); + logger.Info("Ping pong request failed with session expired, trying to renew the session."); await SfSession.renewSessionAsync(cancellationToken).ConfigureAwait(false); } else @@ -796,7 +796,7 @@ internal async Task ExecuteAsyncHelper( } catch (Exception ex) { - s_logger.Error("Query execution failed.", ex); + logger.Error("Query execution failed.", ex); throw; } finally @@ -873,7 +873,7 @@ internal QueryStatus GetQueryStatus(string queryId) } catch { - s_logger.Error("Query execution failed."); + logger.Error("Query execution failed."); throw; } finally @@ -928,7 +928,7 @@ internal async Task GetQueryStatusAsync(string queryId, Cancellatio } catch { - s_logger.Error("Query execution failed."); + logger.Error("Query execution failed."); throw; } finally @@ -991,7 +991,7 @@ internal static string TrimSql(string originalSql) var trimmedQuery = builder.ToString(); trimmedQuery = trimmedQuery.Trim(); - s_logger.Debug("Trimmed query : " + trimmedQuery); + logger.Debug("Trimmed query : " + trimmedQuery); return trimmedQuery; }