mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-13 20:47:24 +00:00
refactor: Reducing duplication
This commit is contained in:
parent
2cd744eb1c
commit
1c89ebc5c2
1 changed files with 7 additions and 17 deletions
|
|
@ -8,16 +8,6 @@ namespace ICD.Common.Utils
|
||||||
{
|
{
|
||||||
public static class IcdErrorLog
|
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;
|
private static readonly SafeCriticalSection s_LoggingSection;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -36,7 +26,7 @@ namespace ICD.Common.Utils
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
message = FormatConsoleColor(message, CONSOLE_RED);
|
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_RED);
|
||||||
ErrorLog.Error(message);
|
ErrorLog.Error(message);
|
||||||
#else
|
#else
|
||||||
System.Console.ForegroundColor = ConsoleColor.Red;
|
System.Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
|
@ -64,7 +54,7 @@ namespace ICD.Common.Utils
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
message = FormatConsoleColor(message, CONSOLE_YELLOW);
|
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_YELLOW);
|
||||||
ErrorLog.Warn(message);
|
ErrorLog.Warn(message);
|
||||||
#else
|
#else
|
||||||
System.Console.ForegroundColor = ConsoleColor.Yellow;
|
System.Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
|
|
@ -92,7 +82,7 @@ namespace ICD.Common.Utils
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
message = FormatConsoleColor(message, CONSOLE_BLUE);
|
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_BLUE);
|
||||||
ErrorLog.Notice(message);
|
ErrorLog.Notice(message);
|
||||||
#else
|
#else
|
||||||
System.Console.ForegroundColor = ConsoleColor.Blue;
|
System.Console.ForegroundColor = ConsoleColor.Blue;
|
||||||
|
|
@ -120,7 +110,7 @@ namespace ICD.Common.Utils
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
message = FormatConsoleColor(message, CONSOLE_GREEN);
|
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_GREEN);
|
||||||
ErrorLog.Ok(message);
|
ErrorLog.Ok(message);
|
||||||
#else
|
#else
|
||||||
System.Console.ForegroundColor = ConsoleColor.Green;
|
System.Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
|
@ -148,7 +138,7 @@ namespace ICD.Common.Utils
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
message = FormatConsoleColor(message, CONSOLE_YELLOW_ON_RED_BACKGROUND);
|
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_YELLOW_ON_RED_BACKGROUND);
|
||||||
ErrorLog.Exception(message, ex);
|
ErrorLog.Exception(message, ex);
|
||||||
#else
|
#else
|
||||||
System.Console.ForegroundColor = ConsoleColor.Yellow;
|
System.Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
|
|
@ -179,7 +169,7 @@ namespace ICD.Common.Utils
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
message = FormatConsoleColor(message, CONSOLE_CYAN);
|
message = FormatConsoleColor(message, ConsoleColorExtensions.CONSOLE_CYAN);
|
||||||
ErrorLog.Info(message);
|
ErrorLog.Info(message);
|
||||||
#else
|
#else
|
||||||
System.Console.ForegroundColor = ConsoleColor.Cyan;
|
System.Console.ForegroundColor = ConsoleColor.Cyan;
|
||||||
|
|
@ -207,7 +197,7 @@ namespace ICD.Common.Utils
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static string FormatConsoleColor(string text, string color)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue