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

@ -33,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
_normalSession.DataAvailable += OnNormalOutData;
_interactiveSession.DataAvailable += OnInteractiveOutData;
Logger.PrintInfo(LogClass.ServiceAm, $"Applet '{appletId}' created.");
Logger.Info?.Print(LogClass.ServiceAm, $"Applet '{appletId}' created.");
}
private void OnAppletStateChanged(object sender, EventArgs e)
@ -194,7 +194,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
context.ResponseData.Write(indirectLayerConsumerHandle);
Logger.PrintStub(LogClass.ServiceAm, new { indirectLayerConsumerHandle });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { indirectLayerConsumerHandle });
return ResultCode.Success;
}

View file

@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
float appletVolume = context.RequestData.ReadSingle();
float libraryAppletVolume = context.RequestData.ReadSingle();
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -24,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
context.ResponseData.Write(1f);
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -35,7 +35,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
context.ResponseData.Write(1f);
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -47,7 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
float unknown0 = context.RequestData.ReadSingle();
long unknown1 = context.RequestData.ReadInt64();
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -58,7 +58,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
float unknown0 = context.RequestData.ReadSingle();
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}

View file

@ -76,7 +76,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
context.ResponseData.Write((byte)0); //Unknown value.
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -120,7 +120,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}

View file

@ -20,7 +20,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// RequestToGetForeground()
public ResultCode RequestToGetForeground(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -36,7 +36,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}

View file

@ -43,7 +43,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
if (transferMem == null)
{
Logger.PrintWarning(LogClass.ServiceAm, $"Invalid TransferMemory Handle: {handle:X}");
Logger.Warning?.Print(LogClass.ServiceAm, $"Invalid TransferMemory Handle: {handle:X}");
return ResultCode.Success; // TODO: Find correct error code
}

View file

@ -41,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// Exit()
public ResultCode Exit(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -50,7 +50,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// LockExit()
public ResultCode LockExit(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -59,7 +59,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// UnlockExit()
public ResultCode UnlockExit(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -110,7 +110,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -121,7 +121,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
bool screenShotPermission = context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServiceAm, new { screenShotPermission });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { screenShotPermission });
_screenShotPermission = screenShotPermission;
@ -134,7 +134,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
bool operationModeChangedNotification = context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServiceAm, new { operationModeChangedNotification });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { operationModeChangedNotification });
_operationModeChangedNotification = operationModeChangedNotification;
@ -147,7 +147,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
bool performanceModeChangedNotification = context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServiceAm, new { performanceModeChangedNotification });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { performanceModeChangedNotification });
_performanceModeChangedNotification = performanceModeChangedNotification;
@ -162,7 +162,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
bool unknownFlag2 = context.RequestData.ReadBoolean();
bool unknownFlag3 = context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServiceAm, new { unknownFlag1, unknownFlag2, unknownFlag3 });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { unknownFlag1, unknownFlag2, unknownFlag3 });
return ResultCode.Success;
}
@ -173,7 +173,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
bool restartMessageEnabled = context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServiceAm, new { restartMessageEnabled });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { restartMessageEnabled });
_restartMessageEnabled = restartMessageEnabled;
@ -186,7 +186,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
bool outOfFocusSuspendingEnabled = context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServiceAm, new { outOfFocusSuspendingEnabled });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { outOfFocusSuspendingEnabled });
_outOfFocusSuspendingEnabled = outOfFocusSuspendingEnabled;
@ -199,7 +199,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
uint screenShotImageOrientation = context.RequestData.ReadUInt32();
Logger.PrintStub(LogClass.ServiceAm, new { screenShotImageOrientation });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { screenShotImageOrientation });
_screenShotImageOrientation = screenShotImageOrientation;
@ -212,7 +212,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
bool handlesRequestToDisplay = context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServiceAm, new { handlesRequestToDisplay });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { handlesRequestToDisplay });
_handlesRequestToDisplay = handlesRequestToDisplay;
@ -225,7 +225,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
uint idleTimeDetectionExtension = context.RequestData.ReadUInt32();
Logger.PrintStub(LogClass.ServiceAm, new { idleTimeDetectionExtension });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { idleTimeDetectionExtension });
_idleTimeDetectionExtension = idleTimeDetectionExtension;
@ -238,7 +238,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
{
context.ResponseData.Write(_idleTimeDetectionExtension);
Logger.PrintStub(LogClass.ServiceAm, new { _idleTimeDetectionExtension });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { _idleTimeDetectionExtension });
return ResultCode.Success;
}

View file

@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// GetAppletResourceUserId() -> nn::applet::AppletResourceUserId
public ResultCode GetAppletResourceUserId(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
context.ResponseData.Write(0L);
@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// AcquireForegroundRights()
public ResultCode AcquireForegroundRights(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}

View file

@ -65,7 +65,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
control.UserAccountSaveDataSize = 0x4000;
control.UserAccountSaveDataJournalSize = 0x4000;
Logger.PrintWarning(LogClass.ServiceAm,
Logger.Warning?.Print(LogClass.ServiceAm,
"No control file was found for this game. Using a dummy one instead. This may cause inaccuracies in some games.");
}
@ -93,7 +93,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
if (firstSupported > (int)SystemState.TitleLanguage.Chinese)
{
Logger.PrintWarning(LogClass.ServiceAm, "Application has zero supported languages");
Logger.Warning?.Print(LogClass.ServiceAm, "Application has zero supported languages");
context.ResponseData.Write(desiredLanguageCode);
@ -107,7 +107,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
SystemLanguage newLanguage = Enum.Parse<SystemLanguage>(Enum.GetName(typeof(SystemState.TitleLanguage), firstSupported));
desiredLanguageCode = SystemStateMgr.GetLanguageCode((int)newLanguage);
Logger.PrintInfo(LogClass.ServiceAm, $"Application doesn't support configured language. Using {newLanguage}");
Logger.Info?.Print(LogClass.ServiceAm, $"Application doesn't support configured language. Using {newLanguage}");
}
context.ResponseData.Write(desiredLanguageCode);
@ -121,7 +121,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
{
Result result = new Result(context.RequestData.ReadUInt32());
Logger.PrintInfo(LogClass.ServiceAm, $"Result = 0x{result.Value:x8} ({result.ToStringWithName()}).");
Logger.Info?.Print(LogClass.ServiceAm, $"Result = 0x{result.Value:x8} ({result.ToStringWithName()}).");
return ResultCode.Success;
}
@ -149,7 +149,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
// TODO: We return a size of 2GB as we use a directory based save system. This should be enough for most of the games.
context.ResponseData.Write(2000000000u);
Logger.PrintStub(LogClass.ServiceAm, new { saveDataType, userId });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { saveDataType, userId });
return ResultCode.Success;
}
@ -170,7 +170,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
context.ResponseData.Write(0L);
context.ResponseData.Write(0L);
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -179,7 +179,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
// InitializeGamePlayRecording(u64, handle<copy>)
public ResultCode InitializeGamePlayRecording(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
Logger.Stub?.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
@ -190,7 +190,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
{
int state = context.RequestData.ReadInt32();
Logger.PrintStub(LogClass.ServiceAm, new { state });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { state });
return ResultCode.Success;
}
@ -201,7 +201,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
{
bool applicationCrashReportEnabled = context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServiceAm, new { applicationCrashReportEnabled });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { applicationCrashReportEnabled });
return ResultCode.Success;
}
@ -246,7 +246,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
{
// TODO: Initialize buffer and object.
Logger.PrintStub(LogClass.ServiceAm, new { transferMemoryAddress, transferMemorySize, width, height });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { transferMemoryAddress, transferMemorySize, width, height });
resultCode = ResultCode.Success;
}
@ -282,7 +282,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
}
}
Logger.PrintStub(LogClass.ServiceAm, new { frameBufferPos, frameBufferSize, x, y, width, height, windowOriginMode });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { frameBufferPos, frameBufferSize, x, y, width, height, windowOriginMode });
return resultCode;
}
@ -296,7 +296,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
}
*/
Logger.PrintStub(LogClass.ServiceAm, new { x, y, width, height, frameBufferPos, frameBufferSize, windowOriginMode });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { x, y, width, height, frameBufferPos, frameBufferSize, windowOriginMode });
return ResultCode.Success;
}
@ -307,7 +307,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
{
bool visible = context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServiceAm, new { visible });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { visible });
// NOTE: It sets an internal field and return ResultCode.Success in all case.
@ -341,7 +341,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
context.ResponseData.Write(previousProgramIndex);
Logger.PrintStub(LogClass.ServiceAm, new { previousProgramIndex });
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { previousProgramIndex });
return ResultCode.Success;
}