Improved Logger (#1292)

* Logger class changes only

Now compile-time checking is possible with the help of Nullable Value
types.

* Misc formatting

* Manual optimizations

PrintGuestLog
PrintGuestStackTrace
Surfaceflinger DequeueBuffer

* Reduce SendVibrationXX log level to Debug

* Add Notice log level

This level is always enabled and used to print system info, etc...
Also, rewrite LogColor to switch expression as colors are static

* Unify unhandled exception event handlers

* Print enabled LogLevels during init

* Re-add App Exit disposes in proper order

nit: switch case spacing

* Revert PrintGuestStackTrace to Info logs due to #1407

PrintGuestStackTrace is now called in some critical error handlers
so revert to old behavior as KThread isn't part of Guest.

* Batch replace Logger statements
This commit is contained in:
mageven 2020-08-04 05:02:53 +05:30 committed by GitHub
parent 60db4c3530
commit a33dc2f491
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
120 changed files with 800 additions and 809 deletions

View file

@ -249,7 +249,7 @@ namespace Ryujinx.Ui
}
else
{
Logger.PrintWarning(LogClass.Application, $"The \"custom_theme_path\" section in \"Config.json\" contains an invalid path: \"{ConfigurationState.Instance.Ui.CustomThemePath}\".");
Logger.Warning?.Print(LogClass.Application, $"The \"custom_theme_path\" section in \"Config.json\" contains an invalid path: \"{ConfigurationState.Instance.Ui.CustomThemePath}\".");
}
}
@ -405,7 +405,7 @@ namespace Ryujinx.Ui
UpdateGraphicsConfig();
Logger.PrintInfo(LogClass.Application, $"Using Firmware Version: {_contentManager.GetCurrentFirmwareVersion()?.VersionString}");
Logger.Notice.Print(LogClass.Application, $"Using Firmware Version: {_contentManager.GetCurrentFirmwareVersion()?.VersionString}");
if (Directory.Exists(path))
{
@ -418,12 +418,12 @@ namespace Ryujinx.Ui
if (romFsFiles.Length > 0)
{
Logger.PrintInfo(LogClass.Application, "Loading as cart with RomFS.");
Logger.Info?.Print(LogClass.Application, "Loading as cart with RomFS.");
device.LoadCart(path, romFsFiles[0]);
}
else
{
Logger.PrintInfo(LogClass.Application, "Loading as cart WITHOUT RomFS.");
Logger.Info?.Print(LogClass.Application, "Loading as cart WITHOUT RomFS.");
device.LoadCart(path);
}
}
@ -432,34 +432,34 @@ namespace Ryujinx.Ui
switch (System.IO.Path.GetExtension(path).ToLowerInvariant())
{
case ".xci":
Logger.PrintInfo(LogClass.Application, "Loading as XCI.");
Logger.Info?.Print(LogClass.Application, "Loading as XCI.");
device.LoadXci(path);
break;
case ".nca":
Logger.PrintInfo(LogClass.Application, "Loading as NCA.");
Logger.Info?.Print(LogClass.Application, "Loading as NCA.");
device.LoadNca(path);
break;
case ".nsp":
case ".pfs0":
Logger.PrintInfo(LogClass.Application, "Loading as NSP.");
Logger.Info?.Print(LogClass.Application, "Loading as NSP.");
device.LoadNsp(path);
break;
default:
Logger.PrintInfo(LogClass.Application, "Loading as homebrew.");
Logger.Info?.Print(LogClass.Application, "Loading as homebrew.");
try
{
device.LoadProgram(path);
}
catch (ArgumentOutOfRangeException)
{
Logger.PrintError(LogClass.Application, "The file which you have specified is unsupported by Ryujinx.");
Logger.Error?.Print(LogClass.Application, "The file which you have specified is unsupported by Ryujinx.");
}
break;
}
}
else
{
Logger.PrintWarning(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file.");
Logger.Warning?.Print(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file.");
device.Dispose();
return;
@ -668,11 +668,12 @@ namespace Ryujinx.Ui
Profile.FinishProfiling();
DiscordIntegrationModule.Exit();
Logger.Shutdown();
Ptc.Dispose();
PtcProfiler.Dispose();
Logger.Shutdown();
Application.Quit();
}
@ -691,7 +692,7 @@ namespace Ryujinx.Ui
}
else
{
Logger.PrintWarning(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out.");
Logger.Warning?.Print(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out.");
}
}
else if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.OpenAl)
@ -702,11 +703,11 @@ namespace Ryujinx.Ui
}
else
{
Logger.PrintWarning(LogClass.Audio, "OpenAL is not supported, trying to fall back to SoundIO.");
Logger.Warning?.Print(LogClass.Audio, "OpenAL is not supported, trying to fall back to SoundIO.");
if (SoundIoAudioOut.IsSupported)
{
Logger.PrintWarning(LogClass.Audio, "Found SoundIO, changing configuration.");
Logger.Warning?.Print(LogClass.Audio, "Found SoundIO, changing configuration.");
ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SoundIo;
SaveConfig();
@ -715,7 +716,7 @@ namespace Ryujinx.Ui
}
else
{
Logger.PrintWarning(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out.");
Logger.Warning?.Print(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out.");
}
}
}
@ -956,7 +957,7 @@ namespace Ryujinx.Ui
dialog.SecondaryText = $"A valid system firmware was not found in {filename}.";
Logger.PrintError(LogClass.Application, $"A valid system firmware was not found in {filename}.");
Logger.Error?.Print(LogClass.Application, $"A valid system firmware was not found in {filename}.");
dialog.Run();
dialog.Hide();
@ -993,7 +994,7 @@ namespace Ryujinx.Ui
if (response == (int)ResponseType.Yes)
{
Logger.PrintInfo(LogClass.Application, $"Installing firmware {firmwareVersion.VersionString}");
Logger.Info?.Print(LogClass.Application, $"Installing firmware {firmwareVersion.VersionString}");
Thread thread = new Thread(() =>
{
@ -1017,7 +1018,7 @@ namespace Ryujinx.Ui
dialog.SecondaryText = $"System version {firmwareVersion.VersionString} successfully installed.";
Logger.PrintInfo(LogClass.Application, $"System version {firmwareVersion.VersionString} successfully installed.");
Logger.Info?.Print(LogClass.Application, $"System version {firmwareVersion.VersionString} successfully installed.");
dialog.Run();
dialog.Dispose();
@ -1038,7 +1039,7 @@ namespace Ryujinx.Ui
dialog.SecondaryText = $"An error occured while installing system version {firmwareVersion.VersionString}." +
" Please check logs for more info.";
Logger.PrintError(LogClass.Application, ex.Message);
Logger.Error?.Print(LogClass.Application, ex.Message);
dialog.Run();
dialog.Dispose();
@ -1073,7 +1074,7 @@ namespace Ryujinx.Ui
dialog.SecondaryText = "An error occured while parsing firmware. Please check the logs for more info.";
Logger.PrintError(LogClass.Application, ex.Message);
Logger.Error?.Print(LogClass.Application, ex.Message);
dialog.Run();
dialog.Dispose();