mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-10-17 22:55:01 +00:00
Flush the error log before exit (ryubing/ryujinx!163)
See merge request ryubing/ryujinx!163
This commit is contained in:
parent
ceec9617ef
commit
51584a083b
@ -187,6 +187,17 @@ namespace Ryujinx.Common.Logging
|
||||
}
|
||||
}
|
||||
|
||||
public static void Flush()
|
||||
{
|
||||
foreach (ILogTarget target in _logTargets)
|
||||
{
|
||||
if (target is AsyncLogTargetWrapper asyncTarget)
|
||||
{
|
||||
asyncTarget.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Shutdown()
|
||||
{
|
||||
Updated = null;
|
||||
|
@ -27,6 +27,17 @@ namespace Ryujinx.Common.Logging.Targets
|
||||
|
||||
private readonly int _overflowTimeout;
|
||||
|
||||
private sealed class FlushEventArgs : LogEventArgs
|
||||
{
|
||||
public readonly ManualResetEventSlim SignalEvent;
|
||||
|
||||
public FlushEventArgs(ManualResetEventSlim signalEvent)
|
||||
: base(LogLevel.Notice, TimeSpan.Zero, string.Empty, string.Empty)
|
||||
{
|
||||
SignalEvent = signalEvent;
|
||||
}
|
||||
}
|
||||
|
||||
string ILogTarget.Name => _target.Name;
|
||||
|
||||
public AsyncLogTargetWrapper(ILogTarget target, int queueLimit = -1, AsyncLogTargetOverflowAction overflowAction = AsyncLogTargetOverflowAction.Block)
|
||||
@ -41,7 +52,15 @@ namespace Ryujinx.Common.Logging.Targets
|
||||
{
|
||||
try
|
||||
{
|
||||
_target.Log(this, _messageQueue.Take());
|
||||
LogEventArgs item = _messageQueue.Take();
|
||||
|
||||
if (item is FlushEventArgs flush)
|
||||
{
|
||||
flush.SignalEvent.Set();
|
||||
continue;
|
||||
}
|
||||
|
||||
_target.Log(this, item);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
@ -68,6 +87,26 @@ namespace Ryujinx.Common.Logging.Targets
|
||||
}
|
||||
}
|
||||
|
||||
public void Flush()
|
||||
{
|
||||
if (_messageQueue.Count == 0 || _messageQueue.IsAddingCompleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var signal = new ManualResetEventSlim(false);
|
||||
try
|
||||
{
|
||||
_messageQueue.Add(new FlushEventArgs(signal));
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
signal.Wait();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
@ -1095,6 +1095,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
Logger.Error?.Print(LogClass.Cpu, $"Invalid memory access at virtual address 0x{va:X16}.");
|
||||
|
||||
Logger.Flush();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1103,6 +1105,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
KernelStatic.GetCurrentThread().PrintGuestStackTrace();
|
||||
KernelStatic.GetCurrentThread()?.PrintGuestRegisterPrintout();
|
||||
|
||||
Logger.Flush();
|
||||
|
||||
throw new UndefinedInstructionException(address, opCode);
|
||||
}
|
||||
|
||||
|
@ -1893,6 +1893,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Error?.Print(LogClass.KernelSvc, "The guest program broke execution!");
|
||||
Logger.Flush();
|
||||
|
||||
// TODO: Debug events.
|
||||
currentThread.Owner.TerminateCurrentProcess();
|
||||
|
||||
|
@ -351,7 +351,10 @@ namespace Ryujinx.Ava
|
||||
|
||||
|
||||
if (isTerminating)
|
||||
{
|
||||
Logger.Flush();
|
||||
Exit();
|
||||
}
|
||||
}
|
||||
|
||||
internal static void Exit()
|
||||
|
Loading…
Reference in New Issue
Block a user