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

@ -123,7 +123,7 @@ namespace Ryujinx.HLE.HOS
if (!xci.HasPartition(XciPartitionType.Secure))
{
Logger.PrintError(LogClass.Loader, "Unable to load XCI: Could not find XCI secure partition");
Logger.Error?.Print(LogClass.Loader, "Unable to load XCI: Could not find XCI secure partition");
return;
}
@ -140,14 +140,14 @@ namespace Ryujinx.HLE.HOS
}
catch (Exception e)
{
Logger.PrintError(LogClass.Loader, $"Unable to load XCI: {e.Message}");
Logger.Error?.Print(LogClass.Loader, $"Unable to load XCI: {e.Message}");
return;
}
if (mainNca == null)
{
Logger.PrintError(LogClass.Loader, "Unable to load XCI: Could not find Main NCA");
Logger.Error?.Print(LogClass.Loader, "Unable to load XCI: Could not find Main NCA");
return;
}
@ -176,14 +176,14 @@ namespace Ryujinx.HLE.HOS
}
catch (Exception e)
{
Logger.PrintError(LogClass.Loader, $"Unable to load NSP: {e.Message}");
Logger.Error?.Print(LogClass.Loader, $"Unable to load NSP: {e.Message}");
return;
}
if (mainNca == null)
{
Logger.PrintError(LogClass.Loader, "Unable to load NSP: Could not find Main NCA");
Logger.Error?.Print(LogClass.Loader, "Unable to load NSP: Could not find Main NCA");
return;
}
@ -215,7 +215,7 @@ namespace Ryujinx.HLE.HOS
{
if (mainNca.Header.ContentType != NcaContentType.Program)
{
Logger.PrintError(LogClass.Loader, "Selected NCA is not a \"Program\" NCA");
Logger.Error?.Print(LogClass.Loader, "Selected NCA is not a \"Program\" NCA");
return;
}
@ -303,7 +303,7 @@ namespace Ryujinx.HLE.HOS
if (codeFs == null)
{
Logger.PrintError(LogClass.Loader, "No ExeFS found in NCA");
Logger.Error?.Print(LogClass.Loader, "No ExeFS found in NCA");
return;
}
@ -323,7 +323,7 @@ namespace Ryujinx.HLE.HOS
if (dataStorage == null)
{
Logger.PrintWarning(LogClass.Loader, "No RomFS found in NCA");
Logger.Warning?.Print(LogClass.Loader, "No RomFS found in NCA");
}
else
{
@ -338,7 +338,7 @@ namespace Ryujinx.HLE.HOS
LoadExeFs(codeFs, metaData);
Logger.PrintInfo(LogClass.Loader, $"Application Loaded: {TitleName} v{DisplayVersion} [{TitleIdText}] [{(TitleIs64Bit ? "64-bit" : "32-bit")}]");
Logger.Info?.Print(LogClass.Loader, $"Application Loaded: {TitleName} v{DisplayVersion} [{TitleIdText}] [{(TitleIs64Bit ? "64-bit" : "32-bit")}]");
}
// Sets TitleId, so be sure to call before using it
@ -349,7 +349,7 @@ namespace Ryujinx.HLE.HOS
if (ResultFs.PathNotFound.Includes(result))
{
Logger.PrintWarning(LogClass.Loader, "NPDM file not found, using default values!");
Logger.Warning?.Print(LogClass.Loader, "NPDM file not found, using default values!");
metaData = GetDefaultNpdm();
}
@ -414,7 +414,7 @@ namespace Ryujinx.HLE.HOS
continue;
}
Logger.PrintInfo(LogClass.Loader, $"Loading {file.Name}...");
Logger.Info?.Print(LogClass.Loader, $"Loading {file.Name}...");
codeFs.OpenFile(out IFile nsoFile, file.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@ -435,7 +435,7 @@ namespace Ryujinx.HLE.HOS
if (EnablePtc && modified)
{
Logger.PrintWarning(LogClass.Ptc, $"Detected exefs modifications. PPTC disabled.");
Logger.Warning?.Print(LogClass.Ptc, $"Detected exefs modifications. PPTC disabled.");
}
Ptc.Initialize(TitleIdText, DisplayVersion, EnablePtc && !modified);
@ -520,7 +520,7 @@ namespace Ryujinx.HLE.HOS
}
else
{
Logger.PrintWarning(LogClass.Loader, $"Unsupported ASET header version found \"{asetVersion}\"");
Logger.Warning?.Print(LogClass.Loader, $"Unsupported ASET header version found \"{asetVersion}\"");
}
}
}
@ -551,7 +551,7 @@ namespace Ryujinx.HLE.HOS
private Result EnsureSaveData(TitleId titleId)
{
Logger.PrintInfo(LogClass.Application, "Ensuring required savedata exists.");
Logger.Info?.Print(LogClass.Application, "Ensuring required savedata exists.");
Uid user = _device.System.State.Account.LastOpenedUser.UserId.ToLibHacUid();
@ -567,7 +567,7 @@ namespace Ryujinx.HLE.HOS
control.UserAccountSaveDataSize = 0x4000;
control.UserAccountSaveDataJournalSize = 0x4000;
Logger.PrintWarning(LogClass.Application,
Logger.Warning?.Print(LogClass.Application,
"No control file was found for this game. Using a dummy one instead. This may cause inaccuracies in some games.");
}
@ -577,7 +577,7 @@ namespace Ryujinx.HLE.HOS
if (rc.IsFailure())
{
Logger.PrintError(LogClass.Application, $"Error calling EnsureApplicationCacheStorage. Result code {rc.ToStringWithName()}");
Logger.Error?.Print(LogClass.Application, $"Error calling EnsureApplicationCacheStorage. Result code {rc.ToStringWithName()}");
return rc;
}
@ -586,7 +586,7 @@ namespace Ryujinx.HLE.HOS
if (rc.IsFailure())
{
Logger.PrintError(LogClass.Application, $"Error calling EnsureApplicationSaveData. Result code {rc.ToStringWithName()}");
Logger.Error?.Print(LogClass.Application, $"Error calling EnsureApplicationSaveData. Result code {rc.ToStringWithName()}");
}
return rc;