From 8650be10209fb384fd131e866f24d8218cb0d6c9 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Wed, 25 Jul 2018 22:25:59 -0400
Subject: [PATCH 1/3] lm: Add missing function entry to Logger's function table

---
 src/core/hle/service/lm/lm.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index e85a8bdb9e..d882f843b0 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -16,6 +16,7 @@ public:
     Logger() : ServiceFramework("Logger") {
         static const FunctionInfo functions[] = {
             {0x00000000, &Logger::Log, "Log"},
+            {0x00000001, nullptr, "SetDestination"},
         };
         RegisterHandlers(functions);
     }

From 6f4d3d8163621f4d21d4d31b21d89073c0124d65 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Wed, 25 Jul 2018 22:27:42 -0400
Subject: [PATCH 2/3] lm: Amend names of Initialize() in Logger and
 Initialize() in LM

Amends these to match the information on Switch Brew.
---
 src/core/hle/service/lm/lm.cpp | 12 ++++++------
 src/core/hle/service/lm/lm.h   |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index d882f843b0..af4573acf0 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -15,7 +15,7 @@ class Logger final : public ServiceFramework<Logger> {
 public:
     Logger() : ServiceFramework("Logger") {
         static const FunctionInfo functions[] = {
-            {0x00000000, &Logger::Log, "Log"},
+            {0x00000000, &Logger::Initialize, "Initialize"},
             {0x00000001, nullptr, "SetDestination"},
         };
         RegisterHandlers(functions);
@@ -67,13 +67,13 @@ private:
     };
 
     /**
-     * LM::Log service function
+     * ILogger::Initialize service function
      *  Inputs:
      *      0: 0x00000000
      *  Outputs:
      *      0: ResultCode
      */
-    void Log(Kernel::HLERequestContext& ctx) {
+    void Initialize(Kernel::HLERequestContext& ctx) {
         // This function only succeeds - Get that out of the way
         IPC::ResponseBuilder rb{ctx, 2};
         rb.Push(RESULT_SUCCESS);
@@ -168,13 +168,13 @@ void InstallInterfaces(SM::ServiceManager& service_manager) {
 }
 
 /**
- * LM::Initialize service function
+ * LM::OpenLogger service function
  *  Inputs:
  *      0: 0x00000000
  *  Outputs:
  *      0: ResultCode
  */
-void LM::Initialize(Kernel::HLERequestContext& ctx) {
+void LM::OpenLogger(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<Logger>();
@@ -184,7 +184,7 @@ void LM::Initialize(Kernel::HLERequestContext& ctx) {
 
 LM::LM() : ServiceFramework("lm") {
     static const FunctionInfo functions[] = {
-        {0x00000000, &LM::Initialize, "Initialize"},
+        {0x00000000, &LM::OpenLogger, "OpenLogger"},
     };
     RegisterHandlers(functions);
 }
diff --git a/src/core/hle/service/lm/lm.h b/src/core/hle/service/lm/lm.h
index 63d6506fe2..9c15c2e5f0 100644
--- a/src/core/hle/service/lm/lm.h
+++ b/src/core/hle/service/lm/lm.h
@@ -16,7 +16,7 @@ public:
     ~LM() = default;
 
 private:
-    void Initialize(Kernel::HLERequestContext& ctx);
+    void OpenLogger(Kernel::HLERequestContext& ctx);
 };
 
 /// Registers all LM services with the specified service manager.

From 91d86df9206c1ed8b417077cd65e6e3a9a7e3d19 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Wed, 25 Jul 2018 22:32:42 -0400
Subject: [PATCH 3/3] lm: Move LM's class declaration into the cpp file

This isn't used directly outside of this translation unit, so we can
hide it from external use.
---
 src/core/hle/service/lm/lm.cpp | 53 ++++++++++++++++++----------------
 src/core/hle/service/lm/lm.h   | 15 ++--------
 2 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index af4573acf0..b497376d7b 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -4,10 +4,12 @@
 
 #include <sstream>
 #include <string>
+
 #include "common/logging/log.h"
 #include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/client_session.h"
 #include "core/hle/service/lm/lm.h"
+#include "core/hle/service/service.h"
+#include "core/memory.h"
 
 namespace Service::LM {
 
@@ -21,8 +23,6 @@ public:
         RegisterHandlers(functions);
     }
 
-    ~Logger() = default;
-
 private:
     struct MessageHeader {
         enum Flags : u32_le {
@@ -163,30 +163,33 @@ private:
     std::ostringstream log_stream;
 };
 
+class LM final : public ServiceFramework<LM> {
+public:
+    explicit LM() : ServiceFramework{"lm"} {
+        static const FunctionInfo functions[] = {
+            {0x00000000, &LM::OpenLogger, "OpenLogger"},
+        };
+        RegisterHandlers(functions);
+    }
+
+    /**
+     * LM::OpenLogger service function
+     *  Inputs:
+     *      0: 0x00000000
+     *  Outputs:
+     *      0: ResultCode
+     */
+    void OpenLogger(Kernel::HLERequestContext& ctx) {
+        IPC::ResponseBuilder rb{ctx, 2, 0, 1};
+        rb.Push(RESULT_SUCCESS);
+        rb.PushIpcInterface<Logger>();
+
+        LOG_DEBUG(Service_LM, "called");
+    }
+};
+
 void InstallInterfaces(SM::ServiceManager& service_manager) {
     std::make_shared<LM>()->InstallAsService(service_manager);
 }
 
-/**
- * LM::OpenLogger service function
- *  Inputs:
- *      0: 0x00000000
- *  Outputs:
- *      0: ResultCode
- */
-void LM::OpenLogger(Kernel::HLERequestContext& ctx) {
-    IPC::ResponseBuilder rb{ctx, 2, 0, 1};
-    rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<Logger>();
-
-    LOG_DEBUG(Service_LM, "called");
-}
-
-LM::LM() : ServiceFramework("lm") {
-    static const FunctionInfo functions[] = {
-        {0x00000000, &LM::OpenLogger, "OpenLogger"},
-    };
-    RegisterHandlers(functions);
-}
-
 } // namespace Service::LM
diff --git a/src/core/hle/service/lm/lm.h b/src/core/hle/service/lm/lm.h
index 9c15c2e5f0..7806ae27bd 100644
--- a/src/core/hle/service/lm/lm.h
+++ b/src/core/hle/service/lm/lm.h
@@ -4,21 +4,12 @@
 
 #pragma once
 
-#include <vector>
-#include "core/hle/kernel/kernel.h"
-#include "core/hle/service/service.h"
+namespace Service::SM {
+class ServiceManager;
+}
 
 namespace Service::LM {
 
-class LM final : public ServiceFramework<LM> {
-public:
-    LM();
-    ~LM() = default;
-
-private:
-    void OpenLogger(Kernel::HLERequestContext& ctx);
-};
-
 /// Registers all LM services with the specified service manager.
 void InstallInterfaces(SM::ServiceManager& service_manager);