From d964d2184ac6813f8aa13a0bab5268637f17b8ac Mon Sep 17 00:00:00 2001 From: jduncanator Date: Mon, 10 Dec 2018 13:26:17 +1100 Subject: [PATCH] Pass the call-sites Thread ID through to the logger --- Ryujinx.Common/Logging/LogEventArgs.cs | 8 +++++--- Ryujinx.Common/Logging/Logger.cs | 3 ++- Ryujinx/Ui/ConsoleLog.cs | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Ryujinx.Common/Logging/LogEventArgs.cs b/Ryujinx.Common/Logging/LogEventArgs.cs index dea2bee14d..ada2c9e93f 100644 --- a/Ryujinx.Common/Logging/LogEventArgs.cs +++ b/Ryujinx.Common/Logging/LogEventArgs.cs @@ -4,15 +4,17 @@ namespace Ryujinx.Common.Logging { public class LogEventArgs : EventArgs { - public LogLevel Level { get; private set; } - public TimeSpan Time { get; private set; } + public LogLevel Level { get; private set; } + public TimeSpan Time { get; private set; } + public int ThreadId { get; private set; } public string Message { get; private set; } - public LogEventArgs(LogLevel level, TimeSpan time, string message) + public LogEventArgs(LogLevel level, TimeSpan time, int threadId, string message) { this.Level = level; this.Time = time; + this.ThreadId = threadId; this.Message = message; } } diff --git a/Ryujinx.Common/Logging/Logger.cs b/Ryujinx.Common/Logging/Logger.cs index 9333088153..107a84faff 100644 --- a/Ryujinx.Common/Logging/Logger.cs +++ b/Ryujinx.Common/Logging/Logger.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; +using System.Threading; namespace Ryujinx.Common.Logging { @@ -116,7 +117,7 @@ namespace Ryujinx.Common.Logging { if (m_EnabledLevels[(int)logLevel] && m_EnabledClasses[(int)logClass]) { - Updated?.Invoke(null, new LogEventArgs(logLevel, m_Time.Elapsed, message)); + Updated?.Invoke(null, new LogEventArgs(logLevel, m_Time.Elapsed, Thread.CurrentThread.ManagedThreadId, message)); } } diff --git a/Ryujinx/Ui/ConsoleLog.cs b/Ryujinx/Ui/ConsoleLog.cs index 67eaa0e35f..dd6b732e8d 100644 --- a/Ryujinx/Ui/ConsoleLog.cs +++ b/Ryujinx/Ui/ConsoleLog.cs @@ -57,7 +57,7 @@ namespace Ryujinx { string formattedTime = e.Time.ToString(@"hh\:mm\:ss\.fff"); - string currentThread = Thread.CurrentThread.ManagedThreadId.ToString("d4"); + string currentThread = e.ThreadId.ToString("d4"); string message = formattedTime + " | " + currentThread + " " + e.Message;