80 lines
2.1 KiB
C#
80 lines
2.1 KiB
C#
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)
|
|
{
|
|
Console.Write(message);
|
|
ResetConsoleColours();
|
|
Console.WriteLine();
|
|
}
|
|
}
|
|
}
|