Fix log exceptions processing escape characters in the headlines.
Some checks failed
Build .NET Project / build (push) Has been cancelled
Some checks failed
Build .NET Project / build (push) Has been cancelled
This commit is contained in:
@@ -232,6 +232,7 @@ namespace MarketData.Utils
|
||||
{
|
||||
return addQuotes?AddQuotes(Utility.DateTimeToStringYYYYHMMHDDHHMMSSTT(dateTime)):Utility.DateTimeToStringYYYYHMMHDDHHMMSSTT(dateTime);
|
||||
}
|
||||
|
||||
public static String SqlString(String value,bool addQuotes=false)
|
||||
{
|
||||
StringBuilder sb=new StringBuilder();
|
||||
@@ -242,9 +243,23 @@ namespace MarketData.Utils
|
||||
}
|
||||
return addQuotes?AddQuotes(sb.ToString()):sb.ToString();
|
||||
}
|
||||
|
||||
public static String ToSqlString(String value)
|
||||
{
|
||||
return SqlString(value,true);
|
||||
}
|
||||
|
||||
public static void LogCommandParameters(String strQuery, MySqlCommand sqlCommand)
|
||||
{
|
||||
try
|
||||
{
|
||||
String paramLog = string.Join(", ", sqlCommand.Parameters.Cast<MySqlParameter>().Select(p => $"{p.ParameterName}='{p.Value}'"));
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, $"Query: {sqlCommand.CommandText} | Parameters: {paramLog}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, "Failed to log query parameters.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user