Fix log exceptions processing escape characters in the headlines.
Some checks failed
Build .NET Project / build (push) Has been cancelled

This commit is contained in:
2026-03-22 11:59:37 -04:00
parent 3c7f41d135
commit b20b05de13
2 changed files with 48 additions and 29 deletions

View File

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