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