Add internal Logging support (#3)
* Add internal Logging support Add class Logging. Replace all Console.WriteLine() to looks better. Add informations inside Windows Titles. * Revert "Add internal Logging support" This reverts commit 275d363aaf30011f238010572cfdb320bd7b627f. * Add internal Logging support Add Logging Class. Replace all Console.WriteLine() to looks better. Add debug informations of IpcMessage. Add informations inside Windows Titles. * Add internal Logging support2 Add Logging Class. Replace all Console.WriteLine() to looks better. Add debug informations of IpcMessage. Add informations inside Windows Titles.
This commit is contained in:
parent
ae91da5b60
commit
9e8f02b66d
7 changed files with 150 additions and 17 deletions
128
Ryujinx/Logging.cs
Normal file
128
Ryujinx/Logging.cs
Normal file
|
@ -0,0 +1,128 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx
|
||||
{
|
||||
public static class Logging
|
||||
{
|
||||
private static Stopwatch ExecutionTime = new Stopwatch();
|
||||
private static string LogFileName = "Ryujinx.log";
|
||||
|
||||
public static bool EnableInfo = true;
|
||||
public static bool EnableTrace = true;
|
||||
public static bool EnableDebug = true;
|
||||
public static bool EnableWarn = true;
|
||||
public static bool EnableError = true;
|
||||
public static bool EnableFatal = true;
|
||||
public static bool EnableLogFile = false;
|
||||
|
||||
static Logging()
|
||||
{
|
||||
ExecutionTime.Start();
|
||||
|
||||
if (File.Exists(LogFileName)) File.Delete(LogFileName);
|
||||
}
|
||||
|
||||
public static string GetExecutionTime()
|
||||
{
|
||||
return ExecutionTime.ElapsedMilliseconds.ToString().PadLeft(8, '0') + "ms";
|
||||
}
|
||||
|
||||
private static void LogFile(string Message)
|
||||
{
|
||||
if (EnableLogFile)
|
||||
{
|
||||
using (StreamWriter Writer = File.AppendText(LogFileName))
|
||||
{
|
||||
Writer.WriteLine(Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Info(string Message)
|
||||
{
|
||||
if (EnableInfo)
|
||||
{
|
||||
string Text = $"{GetExecutionTime()} | INFO > {Message}";
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.WriteLine(Text.PadLeft(Text.Length + 1, ' '));
|
||||
Console.ResetColor();
|
||||
|
||||
LogFile(Text);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Trace(string Message)
|
||||
{
|
||||
if (EnableTrace)
|
||||
{
|
||||
string Text = $"{GetExecutionTime()} | TRACE > {Message}";
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
Console.WriteLine(Text.PadLeft(Text.Length + 1, ' '));
|
||||
Console.ResetColor();
|
||||
|
||||
LogFile(Text);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Debug(string Message)
|
||||
{
|
||||
if (EnableDebug)
|
||||
{
|
||||
string Text = $"{GetExecutionTime()} | DEBUG > {Message}";
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine(Text.PadLeft(Text.Length + 1, ' '));
|
||||
Console.ResetColor();
|
||||
|
||||
LogFile(Text);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Warn(string Message)
|
||||
{
|
||||
if (EnableWarn)
|
||||
{
|
||||
string Text = $"{GetExecutionTime()} | WARN > {Message}";
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine(Text.PadLeft(Text.Length + 1, ' '));
|
||||
Console.ResetColor();
|
||||
|
||||
LogFile(Text);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Error(string Message)
|
||||
{
|
||||
if (EnableError)
|
||||
{
|
||||
string Text = $"{GetExecutionTime()} | ERROR > {Message}";
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine(Text.PadLeft(Text.Length + 1, ' '));
|
||||
Console.ResetColor();
|
||||
|
||||
LogFile(Text);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Fatal(string Message)
|
||||
{
|
||||
if (EnableFatal)
|
||||
{
|
||||
string Text = $"{GetExecutionTime()} | FATAL > {Message}";
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Magenta;
|
||||
Console.WriteLine(Text.PadLeft(Text.Length + 1, ' '));
|
||||
Console.ResetColor();
|
||||
|
||||
LogFile(Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue