0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/Ryujinx/Ui/ConsoleLog.cs

51 lines
1.4 KiB
C#
Raw Normal View History

2018-04-24 18:57:39 +00:00
using Ryujinx.Core.Logging;
using System;
using System.Collections.Generic;
using System.Threading;
namespace Ryujinx
{
static class ConsoleLog
{
private static Dictionary<LogLevel, ConsoleColor> LogColors;
private static object ConsoleLock;
static ConsoleLog()
{
LogColors = new Dictionary<LogLevel, ConsoleColor>()
{
{ LogLevel.Stub, ConsoleColor.DarkGray },
{ LogLevel.Info, ConsoleColor.White },
{ LogLevel.Warning, ConsoleColor.Yellow },
{ LogLevel.Error, ConsoleColor.Red }
};
ConsoleLock = new object();
}
public static void PrintLog(object sender, LogEventArgs e)
{
string FormattedTime = e.Time.ToString(@"hh\:mm\:ss\.fff");
string CurrentThread = Thread.CurrentThread.ManagedThreadId.ToString("d4");
string Message = FormattedTime + " | " + CurrentThread + " " + e.Message;
if (LogColors.TryGetValue(e.Level, out ConsoleColor Color))
{
lock (ConsoleLock)
{
Console.ForegroundColor = Color;
Console.WriteLine(Message);
Console.ResetColor();
}
}
else
{
Console.WriteLine(Message);
}
}
}
}