Use Logger overloads (#2163)

This commit is contained in:
Charles Gagnon
2023-08-02 13:25:21 -07:00
committed by GitHub
parent dc91e1ecf0
commit 969ac0ed8c
114 changed files with 438 additions and 530 deletions

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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());
}
}
}