Flush the error log before exit (ryubing/ryujinx!163)
See merge request ryubing/ryujinx!163
This commit is contained in:
parent
ceec9617ef
commit
51584a083b
5 changed files with 61 additions and 1 deletions
|
|
@ -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()
|
public static void Shutdown()
|
||||||
{
|
{
|
||||||
Updated = null;
|
Updated = null;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,17 @@ namespace Ryujinx.Common.Logging.Targets
|
||||||
|
|
||||||
private readonly int _overflowTimeout;
|
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;
|
string ILogTarget.Name => _target.Name;
|
||||||
|
|
||||||
public AsyncLogTargetWrapper(ILogTarget target, int queueLimit = -1, AsyncLogTargetOverflowAction overflowAction = AsyncLogTargetOverflowAction.Block)
|
public AsyncLogTargetWrapper(ILogTarget target, int queueLimit = -1, AsyncLogTargetOverflowAction overflowAction = AsyncLogTargetOverflowAction.Block)
|
||||||
|
|
@ -41,7 +52,15 @@ namespace Ryujinx.Common.Logging.Targets
|
||||||
{
|
{
|
||||||
try
|
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)
|
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()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
GC.SuppressFinalize(this);
|
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.Error?.Print(LogClass.Cpu, $"Invalid memory access at virtual address 0x{va:X16}.");
|
||||||
|
|
||||||
|
Logger.Flush();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1103,6 +1105,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||||
KernelStatic.GetCurrentThread().PrintGuestStackTrace();
|
KernelStatic.GetCurrentThread().PrintGuestStackTrace();
|
||||||
KernelStatic.GetCurrentThread()?.PrintGuestRegisterPrintout();
|
KernelStatic.GetCurrentThread()?.PrintGuestRegisterPrintout();
|
||||||
|
|
||||||
|
Logger.Flush();
|
||||||
|
|
||||||
throw new UndefinedInstructionException(address, opCode);
|
throw new UndefinedInstructionException(address, opCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1893,6 +1893,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Error?.Print(LogClass.KernelSvc, "The guest program broke execution!");
|
||||||
|
Logger.Flush();
|
||||||
|
|
||||||
// TODO: Debug events.
|
// TODO: Debug events.
|
||||||
currentThread.Owner.TerminateCurrentProcess();
|
currentThread.Owner.TerminateCurrentProcess();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -351,7 +351,10 @@ namespace Ryujinx.Ava
|
||||||
|
|
||||||
|
|
||||||
if (isTerminating)
|
if (isTerminating)
|
||||||
|
{
|
||||||
|
Logger.Flush();
|
||||||
Exit();
|
Exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Exit()
|
internal static void Exit()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue