mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-18 22:25:05 +00:00
Revert "fix: fix for logging deadlock, use mutexes, add logging for last message sent."
This reverts commit 7c238b9fef.
This commit is contained in:
@@ -8,26 +8,23 @@ namespace ICD.Common.Utils
|
||||
{
|
||||
public static class IcdErrorLog
|
||||
{
|
||||
private const int MUTEX_TIMEOUT = 30 * 1000;
|
||||
private static readonly SafeMutex s_SafeMutex;
|
||||
private static string s_LastMessage;
|
||||
private static readonly SafeCriticalSection s_LoggingSection;
|
||||
|
||||
/// <summary>
|
||||
/// Static constructor.
|
||||
/// </summary>
|
||||
static IcdErrorLog()
|
||||
{
|
||||
s_SafeMutex = new SafeMutex();
|
||||
s_LoggingSection = new SafeCriticalSection();
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public static void Error(string message)
|
||||
{
|
||||
if(s_SafeMutex.WaitForMutex(MUTEX_TIMEOUT))
|
||||
{
|
||||
s_LoggingSection.Enter();
|
||||
|
||||
try
|
||||
{
|
||||
s_LastMessage = message;
|
||||
#if SIMPLSHARP
|
||||
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_RED);
|
||||
ErrorLog.Error(message);
|
||||
@@ -39,13 +36,7 @@ namespace ICD.Common.Utils
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_SafeMutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, "Deadlock in Error Logging, last logged message is:");
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, StringUtils.ToMixedReadableHexLiteral(s_LastMessage));
|
||||
s_LoggingSection.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,11 +49,10 @@ namespace ICD.Common.Utils
|
||||
[PublicAPI]
|
||||
public static void Warn(string message)
|
||||
{
|
||||
if (s_SafeMutex.WaitForMutex(MUTEX_TIMEOUT))
|
||||
{
|
||||
s_LoggingSection.Enter();
|
||||
|
||||
try
|
||||
{
|
||||
s_LastMessage = message;
|
||||
#if SIMPLSHARP
|
||||
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_YELLOW);
|
||||
ErrorLog.Warn(message);
|
||||
@@ -74,13 +64,7 @@ namespace ICD.Common.Utils
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_SafeMutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, "Deadlock in Error Logging, last logged message is:");
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, StringUtils.ToMixedReadableHexLiteral(s_LastMessage));
|
||||
s_LoggingSection.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,9 +77,8 @@ namespace ICD.Common.Utils
|
||||
[PublicAPI]
|
||||
public static void Notice(string message)
|
||||
{
|
||||
if (s_SafeMutex.WaitForMutex(MUTEX_TIMEOUT))
|
||||
{
|
||||
s_LastMessage = message;
|
||||
s_LoggingSection.Enter();
|
||||
|
||||
try
|
||||
{
|
||||
#if SIMPLSHARP
|
||||
@@ -109,13 +92,7 @@ namespace ICD.Common.Utils
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_SafeMutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, "Deadlock in Error Logging, last logged message is:");
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, StringUtils.ToMixedReadableHexLiteral(s_LastMessage));
|
||||
s_LoggingSection.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,9 +105,8 @@ namespace ICD.Common.Utils
|
||||
[PublicAPI]
|
||||
public static void Ok(string message)
|
||||
{
|
||||
if (s_SafeMutex.WaitForMutex(MUTEX_TIMEOUT))
|
||||
{
|
||||
s_LastMessage = message;
|
||||
s_LoggingSection.Enter();
|
||||
|
||||
try
|
||||
{
|
||||
#if SIMPLSHARP
|
||||
@@ -144,13 +120,7 @@ namespace ICD.Common.Utils
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_SafeMutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, "Deadlock in Error Logging, last logged message is:");
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, StringUtils.ToMixedReadableHexLiteral(s_LastMessage));
|
||||
s_LoggingSection.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,9 +133,8 @@ namespace ICD.Common.Utils
|
||||
[PublicAPI]
|
||||
public static void Exception(Exception ex, string message)
|
||||
{
|
||||
if (s_SafeMutex.WaitForMutex(MUTEX_TIMEOUT))
|
||||
{
|
||||
s_LastMessage = message;
|
||||
s_LoggingSection.Enter();
|
||||
|
||||
try
|
||||
{
|
||||
#if SIMPLSHARP
|
||||
@@ -181,13 +150,7 @@ namespace ICD.Common.Utils
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_SafeMutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, "Deadlock in Error Logging, last logged message is:");
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, StringUtils.ToMixedReadableHexLiteral(s_LastMessage));
|
||||
s_LoggingSection.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,9 +164,8 @@ namespace ICD.Common.Utils
|
||||
[PublicAPI]
|
||||
public static void Info(string message)
|
||||
{
|
||||
if (s_SafeMutex.WaitForMutex(MUTEX_TIMEOUT))
|
||||
{
|
||||
s_LastMessage = message;
|
||||
s_LoggingSection.Enter();
|
||||
|
||||
try
|
||||
{
|
||||
#if SIMPLSHARP
|
||||
@@ -217,13 +179,7 @@ namespace ICD.Common.Utils
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_SafeMutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, "Deadlock in Error Logging, last logged message is:");
|
||||
IcdConsole.PrintLine(eConsoleColor.YellowOnRed, StringUtils.ToMixedReadableHexLiteral(s_LastMessage));
|
||||
s_LoggingSection.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user