refactor: Reducing duplication

This commit is contained in:
Chris Cameron
2018-06-21 11:32:29 -04:00
parent 2cd744eb1c
commit 1c89ebc5c2

View File

@@ -8,16 +8,6 @@ namespace ICD.Common.Utils
{
public static class IcdErrorLog
{
private const string CONSOLE_RED = "\x1B[31;1m";
private const string CONSOLE_GREEN = "\x1B[32;1m";
private const string CONSOLE_YELLOW = "\x1B[33;1m";
private const string CONSOLE_BLUE = "\x1B[34;1m";
//private const string CONSOLE_MAGENTA = "\x1B[35;1m";
private const string CONSOLE_CYAN = "\x1B[36;1m";
//private const string CONSOLE_WHITE = "\x1B[37;1m";
private const string CONSOLE_YELLOW_ON_RED_BACKGROUND = "\x1B[93;41m";
private const string CONSOLE_RESET = "\x1B[0m";
private static readonly SafeCriticalSection s_LoggingSection;
/// <summary>
@@ -36,7 +26,7 @@ namespace ICD.Common.Utils
try
{
#if SIMPLSHARP
message = FormatConsoleColor(message, CONSOLE_RED);
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_RED);
ErrorLog.Error(message);
#else
System.Console.ForegroundColor = ConsoleColor.Red;
@@ -64,7 +54,7 @@ namespace ICD.Common.Utils
try
{
#if SIMPLSHARP
message = FormatConsoleColor(message, CONSOLE_YELLOW);
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_YELLOW);
ErrorLog.Warn(message);
#else
System.Console.ForegroundColor = ConsoleColor.Yellow;
@@ -92,7 +82,7 @@ namespace ICD.Common.Utils
try
{
#if SIMPLSHARP
message = FormatConsoleColor(message, CONSOLE_BLUE);
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_BLUE);
ErrorLog.Notice(message);
#else
System.Console.ForegroundColor = ConsoleColor.Blue;
@@ -120,7 +110,7 @@ namespace ICD.Common.Utils
try
{
#if SIMPLSHARP
message = FormatConsoleColor(message, CONSOLE_GREEN);
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_GREEN);
ErrorLog.Ok(message);
#else
System.Console.ForegroundColor = ConsoleColor.Green;
@@ -148,7 +138,7 @@ namespace ICD.Common.Utils
try
{
#if SIMPLSHARP
message = FormatConsoleColor(message, CONSOLE_YELLOW_ON_RED_BACKGROUND);
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_YELLOW_ON_RED_BACKGROUND);
ErrorLog.Exception(message, ex);
#else
System.Console.ForegroundColor = ConsoleColor.Yellow;
@@ -179,7 +169,7 @@ namespace ICD.Common.Utils
try
{
#if SIMPLSHARP
message = FormatConsoleColor(message, CONSOLE_CYAN);
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_CYAN);
ErrorLog.Info(message);
#else
System.Console.ForegroundColor = ConsoleColor.Cyan;
@@ -207,7 +197,7 @@ namespace ICD.Common.Utils
/// <returns></returns>
private static string FormatConsoleColor(string text, string color)
{
return string.Format("{0}{1}{2}", color, text, CONSOLE_RESET);
return string.Format("{0}{1}{2}", color, text, ConsoleColorExtensions.CONSOLE_RESET);
}
}
}