mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-31 17:24:37 -05:00
Use Logger overloads (#2163)
This commit is contained in:
@@ -9,7 +9,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode;
|
||||
using System.Globalization;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.SqlTools.ManagedBatchParser;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.BatchParser
|
||||
@@ -354,7 +353,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser
|
||||
if (args != null)
|
||||
{
|
||||
|
||||
Logger.Write(TraceEventType.Verbose, SR.BatchParserWrapperExecutionError);
|
||||
Logger.Verbose(SR.BatchParserWrapperExecutionError);
|
||||
throw new Exception(string.Format(CultureInfo.CurrentCulture,
|
||||
SR.BatchParserWrapperExecutionEngineError, args.Message + Environment.NewLine + '\t' + args.Description));
|
||||
|
||||
@@ -396,7 +395,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser
|
||||
catch (Exception e)
|
||||
{
|
||||
// adding this for debugging
|
||||
Logger.Write(TraceEventType.Warning, "Exception Caught in BatchParserWrapper.OnBatchParserExecutionFinished(...)" + e.ToString());
|
||||
Logger.Warning("Exception Caught in BatchParserWrapper.OnBatchParserExecutionFinished(...)" + e.ToString());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -415,7 +414,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser
|
||||
if (args != null)
|
||||
{
|
||||
|
||||
Logger.Write(TraceEventType.Information, SR.BatchParserWrapperExecutionEngineError);
|
||||
Logger.Information(SR.BatchParserWrapperExecutionEngineError);
|
||||
throw new Exception(SR.BatchParserWrapperExecutionEngineError);
|
||||
|
||||
}
|
||||
@@ -426,7 +425,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser
|
||||
#if DEBUG
|
||||
if (args != null)
|
||||
{
|
||||
Logger.Write(TraceEventType.Information, SR.BatchParserWrapperExecutionEngineBatchMessage);
|
||||
Logger.Information(SR.BatchParserWrapperExecutionEngineBatchMessage);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -436,7 +435,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser
|
||||
#if DEBUG
|
||||
if (args != null && args.DataReader != null)
|
||||
{
|
||||
Logger.Write(TraceEventType.Information, SR.BatchParserWrapperExecutionEngineBatchResultSetProcessing);
|
||||
Logger.Information(SR.BatchParserWrapperExecutionEngineBatchResultSetProcessing);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -444,13 +443,13 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser
|
||||
public void OnBatchResultSetFinished(object sender, EventArgs args)
|
||||
{
|
||||
#if DEBUG
|
||||
Logger.Write(TraceEventType.Information, SR.BatchParserWrapperExecutionEngineBatchResultSetFinished);
|
||||
Logger.Information(SR.BatchParserWrapperExecutionEngineBatchResultSetFinished);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void OnBatchCancelling(object sender, EventArgs args)
|
||||
{
|
||||
Logger.Write(TraceEventType.Information, SR.BatchParserWrapperExecutionEngineBatchCancelling);
|
||||
Logger.Information(SR.BatchParserWrapperExecutionEngineBatchCancelling);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -724,7 +724,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode
|
||||
|
||||
if (messageHandler == null)
|
||||
{
|
||||
Logger.Write(TraceEventType.Error, "Expected handler to be declared");
|
||||
Logger.Error("Expected handler to be declared");
|
||||
}
|
||||
|
||||
if (null != connectionWrapper)
|
||||
@@ -737,7 +737,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode
|
||||
|
||||
if (statementCompletedHandler == null)
|
||||
{
|
||||
Logger.Write(TraceEventType.Error, "Expect handler to be declared if we have a command wrapper");
|
||||
Logger.Error("Expect handler to be declared if we have a command wrapper");
|
||||
}
|
||||
commandWrapper.StatementCompleted -= statementCompletedHandler;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode
|
||||
catch (Exception ex)
|
||||
{
|
||||
// if anything goes wrong it will shutdown VS
|
||||
Logger.Write(TraceEventType.Error, "Exception Caught in ExecutionEngine.DoBatchExecution(Batch) :" + ex.ToString());
|
||||
Logger.Error("Exception Caught in ExecutionEngine.DoBatchExecution(Batch) :" + ex.ToString());
|
||||
result = ScriptExecutionResult.Failure;
|
||||
}
|
||||
}
|
||||
@@ -496,7 +496,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(TraceEventType.Warning, "Exception Caught in ExecutionEngine.DoScriptExecution(bool): " + ex.ToString());
|
||||
Logger.Warning("Exception Caught in ExecutionEngine.DoScriptExecution(bool): " + ex.ToString());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -926,7 +926,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode
|
||||
}
|
||||
catch (SqlException ex)
|
||||
{
|
||||
Logger.Write(TraceEventType.Warning, "Exception Caught in ExecutionEngine.ConnectSqlCmdInternal(SqlConnectionStringBuilder): " + ex.ToString());
|
||||
Logger.Warning("Exception Caught in ExecutionEngine.ConnectSqlCmdInternal(SqlConnectionStringBuilder): " + ex.ToString());
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -962,7 +962,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode
|
||||
}
|
||||
catch (SqlException ex)
|
||||
{
|
||||
Logger.Write(TraceEventType.Warning, "Exception Caught in ExecutionEngine.CloseConnection(SqlConnection): " + ex.ToString());
|
||||
Logger.Warning("Exception Caught in ExecutionEngine.CloseConnection(SqlConnection): " + ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
//
|
||||
namespace Microsoft.SqlTools.ManagedBatchParser
|
||||
{
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Globalization;
|
||||
|
||||
@@ -351,7 +351,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
public void TraceSettings()
|
||||
{
|
||||
// NOTE: logging as warning so we can get this data in the IEService DacFx logs
|
||||
Logger.Write(TraceEventType.Warning, Resources.LoggingAmbientSettings);
|
||||
Logger.Warning(Resources.LoggingAmbientSettings);
|
||||
|
||||
foreach (KeyValuePair<string, AmbientValue> setting in _configuration)
|
||||
{
|
||||
@@ -407,7 +407,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Write(TraceEventType.Error, string.Format(Resources.UnableToAssignValue, value.GetType().FullName, _type.FullName));
|
||||
Logger.Error(string.Format(Resources.UnableToAssignValue, value.GetType().FullName, _type.FullName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Data;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
using Microsoft.SqlServer.Management.Dmf;
|
||||
@@ -296,7 +295,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.Write(TraceEventType.Error, String.Format(Resources.FailedToParseConnectionString, connection.ConnectionString));
|
||||
Logger.Error( String.Format(Resources.FailedToParseConnectionString, connection.ConnectionString));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
Validate.IsNotNull(nameof(connection), connection);
|
||||
if (!(connection.State == ConnectionState.Open))
|
||||
{
|
||||
Logger.Write(TraceEventType.Warning, Resources.ConnectionPassedToIsCloudShouldBeOpen);
|
||||
Logger.Warning(Resources.ConnectionPassedToIsCloudShouldBeOpen);
|
||||
}
|
||||
|
||||
Func<string, DatabaseEngineEdition> executeCommand = commandText =>
|
||||
@@ -514,7 +514,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
return true;
|
||||
}
|
||||
|
||||
Logger.Write(TraceEventType.Error, ex.ToString());
|
||||
Logger.Error(ex.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -641,7 +641,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
},
|
||||
(ex) =>
|
||||
{
|
||||
Logger.Write(TraceEventType.Error, ex.ToString());
|
||||
Logger.Error(ex.ToString());
|
||||
return StandardExceptionHandler(ex); // handled
|
||||
},
|
||||
useRetry: true,
|
||||
@@ -801,7 +801,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
// since these properties are not available for types of sql servers and users
|
||||
// and it is not essential to always include them
|
||||
// just logging the errors here and moving on with the workflow.
|
||||
Logger.Write(TraceEventType.Error, ex.ToString());
|
||||
Logger.Error(ex.ToString());
|
||||
}
|
||||
return sysInfo;
|
||||
}
|
||||
@@ -814,7 +814,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
Validate.IsNotNull(nameof(connection), connection);
|
||||
if (!(connection.State == ConnectionState.Open))
|
||||
{
|
||||
Logger.Write(TraceEventType.Error, "connection passed to GetServerVersion should be open.");
|
||||
Logger.Error("connection passed to GetServerVersion should be open.");
|
||||
}
|
||||
|
||||
Func<string, ServerInfo> getServerInfo = commandText =>
|
||||
@@ -865,8 +865,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
{
|
||||
//we don't want to fail the normal flow if any unexpected thing happens
|
||||
//during caching although it's unlikely. So we just log the exception and ignore it
|
||||
Logger.Write(TraceEventType.Error, Resources.FailedToCacheIsCloud);
|
||||
Logger.Write(TraceEventType.Error, ex.ToString());
|
||||
Logger.Error(Resources.FailedToCacheIsCloud);
|
||||
Logger.Error(ex.ToString());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -976,7 +976,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
|
||||
if (handledEx != null)
|
||||
{
|
||||
Logger.Write(TraceEventType.Error, String.Format(Resources.ErrorParsingConnectionString, handledEx));
|
||||
Logger.Error(String.Format(Resources.ErrorParsingConnectionString, handledEx));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -453,7 +453,7 @@ SET NUMERIC_ROUNDABORT OFF;";
|
||||
string sessionId = (string)command.ExecuteScalar();
|
||||
if (!Guid.TryParse(sessionId, out _azureSessionId))
|
||||
{
|
||||
Logger.Write(TraceEventType.Error, Resources.UnableToRetrieveAzureSessionId);
|
||||
Logger.Error(Resources.UnableToRetrieveAzureSessionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -461,7 +461,7 @@ SET NUMERIC_ROUNDABORT OFF;";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.Write(TraceEventType.Error, Resources.UnableToRetrieveAzureSessionId + exception.ToString());
|
||||
Logger.Error(Resources.UnableToRetrieveAzureSessionId + exception.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
//
|
||||
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.SqlTools.BatchParser.Utility;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
@@ -31,7 +30,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
RetryPolicyUtils.AppendThrottlingDataIfIsThrottlingError(sqlException, err);
|
||||
if (RetryPolicyUtils.IsNonRetryableDataTransferError(err.Number))
|
||||
{
|
||||
Logger.Write(TraceEventType.Error, string.Format(Resources.ExceptionCannotBeRetried, err.Number, err.Message));
|
||||
Logger.Error(string.Format(Resources.ExceptionCannotBeRetried, err.Number, err.Message));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
bool shouldRetry = canRetry
|
||||
&& ShouldRetryImpl(retryState);
|
||||
|
||||
Logger.Write(TraceEventType.Error,
|
||||
Logger.Error(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Retry requested: Retry count = {0}. Delay = {1}, SQL Error Number = {2}, Can retry error = {3}, Will retry = {4}",
|
||||
@@ -267,7 +267,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
{
|
||||
bool shouldIgnoreError = ErrorDetectionStrategy.ShouldIgnoreError(retryState.LastError);
|
||||
|
||||
Logger.Write(TraceEventType.Error,
|
||||
Logger.Error(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Ignore Error requested: Retry count = {0}. Delay = {1}, SQL Error Number = {2}, Should Ignore Error = {3}",
|
||||
|
||||
@@ -392,7 +392,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
|
||||
public static void DataConnectionFailureRetry(RetryState retryState)
|
||||
{
|
||||
Logger.Write(TraceEventType.Information, string.Format(CultureInfo.InvariantCulture,
|
||||
Logger.Information(string.Format(CultureInfo.InvariantCulture,
|
||||
"Connection retry number {0}. Delaying {1} ms before retry. Exception: {2}",
|
||||
retryState.RetryCount,
|
||||
retryState.Delay.TotalMilliseconds.ToString(CultureInfo.InvariantCulture),
|
||||
@@ -403,7 +403,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
|
||||
public static void CommandFailureRetry(RetryState retryState, string commandKeyword)
|
||||
{
|
||||
Logger.Write(TraceEventType.Information, string.Format(
|
||||
Logger.Information(string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} retry number {1}. Delaying {2} ms before retry. Exception: {3}",
|
||||
commandKeyword,
|
||||
@@ -416,7 +416,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
|
||||
public static void CommandFailureIgnore(RetryState retryState, string commandKeyword)
|
||||
{
|
||||
Logger.Write(TraceEventType.Information, string.Format(
|
||||
Logger.Information(string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0} retry number {1}. Ignoring failure. Exception: {2}",
|
||||
commandKeyword,
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.SqlTools.BatchParser.Utility;
|
||||
|
||||
@@ -345,7 +344,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
||||
{
|
||||
if (azureSessionId != Guid.Empty)
|
||||
{
|
||||
Logger.Write(TraceEventType.Warning, string.Format(
|
||||
Logger.Warning(string.Format(
|
||||
"Retry occurred: session: {0}; attempt - {1}; delay - {2}; exception - \"{3}\"",
|
||||
azureSessionId,
|
||||
retryState.RetryCount,
|
||||
|
||||
Reference in New Issue
Block a user