Implement OutputAccessLogToSdCard and expose an FS access log option (#700)

* Add OutputAccessLogToSdCard

* Add config options for the FS access log
This commit is contained in:
Alex Barney 2019-06-15 20:31:18 -05:00 committed by Ac_K
parent afc00b1a7b
commit 4b2e5dcb30
9 changed files with 136 additions and 20 deletions

View file

@ -1,6 +1,7 @@
using LibHac;
using LibHac.Fs;
using LibHac.Fs.NcaUtils;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.Utilities;
@ -32,7 +33,8 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
{ 200, OpenDataStorageByCurrentProcess },
{ 202, OpenDataStorageByDataId },
{ 203, OpenPatchDataStorageByCurrentProcess },
{ 1005, GetGlobalAccessLogMode }
{ 1005, GetGlobalAccessLogMode },
{ 1006, OutputAccessLogToSdCard }
};
}
@ -208,7 +210,20 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
// GetGlobalAccessLogMode() -> u32 logMode
public long GetGlobalAccessLogMode(ServiceCtx context)
{
context.ResponseData.Write(0);
int mode = context.Device.System.GlobalAccessLogMode;
context.ResponseData.Write(mode);
return 0;
}
// OutputAccessLogToSdCard(buffer<bytes, 5> log_text)
public long OutputAccessLogToSdCard(ServiceCtx context)
{
string message = ReadUtf8StringSend(context);
// FS ends each line with a newline. Remove it because Ryujinx logging adds its own newline
Logger.PrintAccessLog(LogClass.ServiceFs, message.TrimEnd('\n'));
return 0;
}

View file

@ -41,6 +41,8 @@ namespace Ryujinx.HLE.HOS.Services.Lm
sb.AppendLine("Guest log:");
sb.AppendLine($" Log level: {(LmLogLevel)level}");
while (ms.Position < ms.Length)
{
byte type = reader.ReadByte();
@ -86,14 +88,7 @@ namespace Ryujinx.HLE.HOS.Services.Lm
string text = sb.ToString();
switch((LmLogLevel)level)
{
case LmLogLevel.Trace: Logger.PrintDebug (LogClass.ServiceLm, text); break;
case LmLogLevel.Info: Logger.PrintInfo (LogClass.ServiceLm, text); break;
case LmLogLevel.Warning: Logger.PrintWarning(LogClass.ServiceLm, text); break;
case LmLogLevel.Error: Logger.PrintError (LogClass.ServiceLm, text); break;
case LmLogLevel.Critical: Logger.PrintError (LogClass.ServiceLm, text); break;
}
Logger.PrintGuest(LogClass.ServiceLm, text);
}
return 0;