2021-09-19 18:29:16 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace MarketPriceLookup.Common.Helpers
|
|
|
|
|
{
|
|
|
|
|
public static class LoggingHelpers
|
|
|
|
|
{
|
|
|
|
|
public static string LogTimeTaken(double totalSeconds)
|
|
|
|
|
{
|
|
|
|
|
return Math.Round(totalSeconds, 2, MidpointRounding.ToEven).ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void LogWarning(string message)
|
|
|
|
|
{
|
|
|
|
|
Console.BackgroundColor = ConsoleColor.DarkYellow;
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Black;
|
|
|
|
|
|
|
|
|
|
LogMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void LogInfo(string message)
|
|
|
|
|
{
|
|
|
|
|
Console.BackgroundColor = ConsoleColor.Gray;
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Black;
|
|
|
|
|
|
|
|
|
|
LogMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void LogSuccess(string message)
|
|
|
|
|
{
|
|
|
|
|
Console.BackgroundColor = ConsoleColor.Green;
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Black;
|
|
|
|
|
|
|
|
|
|
LogMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void LogError(string message)
|
|
|
|
|
{
|
|
|
|
|
Console.BackgroundColor = ConsoleColor.Red;
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.White;
|
|
|
|
|
|
|
|
|
|
LogMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void LogToConsole(string message, ConsoleColor backgroundColour = ConsoleColor.Green)
|
|
|
|
|
{
|
|
|
|
|
Console.BackgroundColor = backgroundColour;
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Black;
|
|
|
|
|
|
|
|
|
|
LogMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ResetConsoleColours()
|
|
|
|
|
{
|
|
|
|
|
Console.BackgroundColor = ConsoleColor.Black;
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.White;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void LogNewLine()
|
|
|
|
|
{
|
|
|
|
|
ResetConsoleColours();
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void LogHeading(string message)
|
|
|
|
|
{
|
|
|
|
|
Console.BackgroundColor = ConsoleColor.Cyan;
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Black;
|
|
|
|
|
|
|
|
|
|
LogMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void LogMessage(string message)
|
|
|
|
|
{
|
2023-04-12 13:23:31 +01:00
|
|
|
|
Console.WriteLine(message);
|
2021-09-19 18:29:16 +01:00
|
|
|
|
ResetConsoleColours();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|