From e0b0f4eece7e9ef5b4223056d622c5ce13836151 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Wed, 15 Aug 2018 00:23:45 -0400
Subject: [PATCH 1/2] lm: Handle threads and modules within the logger

The thread field serves to indicate which thread a log is related to and
provides the length of the thread's name, so we can print that out,
ditto for modules.

Now we can know what threads are potentially spawning off logging
messages (for example Lydie & Suelle bounces between MainThread and
LoadingThread when initializing the game).
---
 src/core/hle/service/lm/lm.cpp | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index 2e99ddf51b..7d054fc43d 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -92,7 +92,11 @@ private:
 
         // Parse out log metadata
         u32 line{};
-        std::string message, filename, function;
+        std::string module;
+        std::string message;
+        std::string filename;
+        std::string function;
+        std::string thread;
         while (addr < end_addr) {
             const Field field{static_cast<Field>(Memory::Read8(addr++))};
             const size_t length{Memory::Read8(addr++)};
@@ -102,6 +106,8 @@ private:
             }
 
             switch (field) {
+            case Field::Skip:
+                break;
             case Field::Message:
                 message = Memory::ReadCString(addr, length);
                 break;
@@ -114,6 +120,12 @@ private:
             case Field::Function:
                 function = Memory::ReadCString(addr, length);
                 break;
+            case Field::Module:
+                module = Memory::ReadCString(addr, length);
+                break;
+            case Field::Thread:
+                thread = Memory::ReadCString(addr, length);
+                break;
             }
 
             addr += length;
@@ -128,12 +140,18 @@ private:
         if (!filename.empty()) {
             log_stream << filename << ':';
         }
+        if (!module.empty()) {
+            log_stream << module << ':';
+        }
         if (!function.empty()) {
             log_stream << function << ':';
         }
         if (line) {
             log_stream << std::to_string(line) << ':';
         }
+        if (!thread.empty()) {
+            log_stream << thread << ':';
+        }
         if (log_stream.str().length() > 0 && log_stream.str().back() == ':') {
             log_stream << ' ';
         }

From b74df629591c890471d6a6b372d70bd0cf738934 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Wed, 15 Aug 2018 01:07:39 -0400
Subject: [PATCH 2/2] lm: Use LOG_DEBUG for printing out trace logs

Using LOG_TRACE here isn't a good idea because LOG_TRACE is only enabled
when yuzu is compiled in debug mode. Debug mode is also quite slow, and
so we're potentially throwing away logging messages that can provide
value when trying to boot games.
---
 src/core/hle/service/lm/lm.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index 7d054fc43d..098da2a41a 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -160,7 +160,7 @@ private:
         if (header.IsTailLog()) {
             switch (header.severity) {
             case MessageHeader::Severity::Trace:
-                LOG_TRACE(Debug_Emulated, "{}", log_stream.str());
+                LOG_DEBUG(Debug_Emulated, "{}", log_stream.str());
                 break;
             case MessageHeader::Severity::Info:
                 LOG_INFO(Debug_Emulated, "{}", log_stream.str());