51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Threading.Tasks;
|
|
using Discord;
|
|
|
|
namespace DeukBot4
|
|
{
|
|
public static class Logger
|
|
{
|
|
private static readonly Dictionary<LogSeverity, ConsoleColor> Colors = new Dictionary<LogSeverity, ConsoleColor>
|
|
{
|
|
{LogSeverity.Info, ConsoleColor.Black},
|
|
{LogSeverity.Verbose, ConsoleColor.Black},
|
|
{LogSeverity.Debug, ConsoleColor.Black},
|
|
{LogSeverity.Warning, ConsoleColor.Yellow},
|
|
{LogSeverity.Error, ConsoleColor.Red},
|
|
{LogSeverity.Critical, ConsoleColor.Red}
|
|
};
|
|
|
|
public static async Task Log(object o, LogSeverity severity)
|
|
{
|
|
Console.ForegroundColor = Colors[severity];
|
|
Console.WriteLine($"[{severity}] {DateTime.UtcNow.ToShortTimeString()}: {o.ToString()}");
|
|
Console.ResetColor();
|
|
}
|
|
|
|
public static async Task LogDiscord(LogMessage message)
|
|
{
|
|
Console.ForegroundColor = Colors[message.Severity];
|
|
Console.WriteLine($"[{message.Severity}] {DateTime.UtcNow.ToShortTimeString()}: {message.Message}");
|
|
Console.ResetColor();
|
|
}
|
|
|
|
public static async Task Log(object o)
|
|
{
|
|
await Log(o, LogSeverity.Info);
|
|
}
|
|
|
|
public static async Task LogWarning(object o)
|
|
{
|
|
await Log(o, LogSeverity.Warning);
|
|
}
|
|
|
|
public static async Task LogError(object o)
|
|
{
|
|
await Log(o, LogSeverity.Error);
|
|
}
|
|
|
|
}
|
|
} |