1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-19 10:02:00 +00:00
Ryujinx/Ryujinx.Common/Logging/Targets/ConsoleLogTarget.cs
Nicholas Rodine 951700fdd8
Removed unused usings. (#3593)
* Removed unused usings.

* Added back using, now that it's used.

* Removed extra whitespace.
2022-08-18 18:04:54 +02:00

41 lines
1.2 KiB
C#

using System;
namespace Ryujinx.Common.Logging
{
public class ConsoleLogTarget : ILogTarget
{
private readonly ILogFormatter _formatter;
private readonly string _name;
string ILogTarget.Name { get => _name; }
private static ConsoleColor GetLogColor(LogLevel level) => level switch {
LogLevel.Info => ConsoleColor.White,
LogLevel.Warning => ConsoleColor.Yellow,
LogLevel.Error => ConsoleColor.Red,
LogLevel.Stub => ConsoleColor.DarkGray,
LogLevel.Notice => ConsoleColor.Cyan,
LogLevel.Trace => ConsoleColor.DarkCyan,
_ => ConsoleColor.Gray,
};
public ConsoleLogTarget(string name)
{
_formatter = new DefaultLogFormatter();
_name = name;
}
public void Log(object sender, LogEventArgs args)
{
Console.ForegroundColor = GetLogColor(args.Level);
Console.WriteLine(_formatter.Format(args));
Console.ResetColor();
}
public void Dispose()
{
Console.ResetColor();
}
}
}