entity-manager: move logDeviceAdded/Removed

functions do not need to be 'inline' and since they are normal
functions, they can go into a .cpp file to be compiled separately.

Functions otherwise unchanged.

Tested: Inspection only.

References:
[1] https://en.cppreference.com/w/cpp/language/inline.html

Change-Id: I194d86f17f90d54d6be2286a52482457435f4c36
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/entity_manager.cpp b/src/entity_manager/entity_manager.cpp
index b191bf0..83240be 100644
--- a/src/entity_manager/entity_manager.cpp
+++ b/src/entity_manager/entity_manager.cpp
@@ -21,6 +21,7 @@
 #include "../variant_visitors.hpp"
 #include "configuration.hpp"
 #include "dbus_interface.hpp"
+#include "log_device_inventory.hpp"
 #include "overlay.hpp"
 #include "perform_scan.hpp"
 #include "phosphor-logging/lg2.hpp"
diff --git a/src/entity_manager/entity_manager.hpp b/src/entity_manager/entity_manager.hpp
index 8aa8935..4bc6d11 100644
--- a/src/entity_manager/entity_manager.hpp
+++ b/src/entity_manager/entity_manager.hpp
@@ -17,14 +17,11 @@
 
 #pragma once
 
-#include "../utils.hpp"
 #include "configuration.hpp"
 #include "dbus_interface.hpp"
 #include "power_status_monitor.hpp"
 #include "topology.hpp"
 
-#include <systemd/sd-journal.h>
-
 #include <boost/container/flat_map.hpp>
 #include <nlohmann/json.hpp>
 #include <sdbusplus/asio/connection.hpp>
@@ -92,111 +89,3 @@
                            nlohmann::json& systemConfiguration);
     void initFilters(const std::unordered_set<std::string>& probeInterfaces);
 };
-
-inline void logDeviceAdded(const nlohmann::json& record)
-{
-    if (!deviceHasLogging(record))
-    {
-        return;
-    }
-    auto findType = record.find("Type");
-    auto findAsset =
-        record.find("xyz.openbmc_project.Inventory.Decorator.Asset");
-
-    std::string model = "Unknown";
-    std::string type = "Unknown";
-    std::string sn = "Unknown";
-    std::string name = "Unknown";
-
-    if (findType != record.end())
-    {
-        type = findType->get<std::string>();
-    }
-    if (findAsset != record.end())
-    {
-        auto findModel = findAsset->find("Model");
-        auto findSn = findAsset->find("SerialNumber");
-        if (findModel != findAsset->end())
-        {
-            model = findModel->get<std::string>();
-        }
-        if (findSn != findAsset->end())
-        {
-            const std::string* getSn = findSn->get_ptr<const std::string*>();
-            if (getSn != nullptr)
-            {
-                sn = *getSn;
-            }
-            else
-            {
-                sn = findSn->dump();
-            }
-        }
-    }
-
-    auto findName = record.find("Name");
-    if (findName != record.end())
-    {
-        name = findName->get<std::string>();
-    }
-
-    sd_journal_send("MESSAGE=Inventory Added: %s", name.c_str(), "PRIORITY=%i",
-                    LOG_INFO, "REDFISH_MESSAGE_ID=%s",
-                    "OpenBMC.0.1.InventoryAdded",
-                    "REDFISH_MESSAGE_ARGS=%s,%s,%s", model.c_str(),
-                    type.c_str(), sn.c_str(), "NAME=%s", name.c_str(), NULL);
-}
-
-inline void logDeviceRemoved(const nlohmann::json& record)
-{
-    if (!deviceHasLogging(record))
-    {
-        return;
-    }
-    auto findType = record.find("Type");
-    auto findAsset =
-        record.find("xyz.openbmc_project.Inventory.Decorator.Asset");
-
-    std::string model = "Unknown";
-    std::string type = "Unknown";
-    std::string sn = "Unknown";
-    std::string name = "Unknown";
-
-    if (findType != record.end())
-    {
-        type = findType->get<std::string>();
-    }
-    if (findAsset != record.end())
-    {
-        auto findModel = findAsset->find("Model");
-        auto findSn = findAsset->find("SerialNumber");
-        if (findModel != findAsset->end())
-        {
-            model = findModel->get<std::string>();
-        }
-        if (findSn != findAsset->end())
-        {
-            const std::string* getSn = findSn->get_ptr<const std::string*>();
-            if (getSn != nullptr)
-            {
-                sn = *getSn;
-            }
-            else
-            {
-                sn = findSn->dump();
-            }
-        }
-    }
-
-    auto findName = record.find("Name");
-    if (findName != record.end())
-    {
-        name = findName->get<std::string>();
-    }
-
-    sd_journal_send("MESSAGE=Inventory Removed: %s", name.c_str(),
-                    "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s",
-                    "OpenBMC.0.1.InventoryRemoved",
-                    "REDFISH_MESSAGE_ARGS=%s,%s,%s", model.c_str(),
-                    type.c_str(), sn.c_str(), "NAME=%s", name.c_str(), NULL);
-}
diff --git a/src/entity_manager/log_device_inventory.cpp b/src/entity_manager/log_device_inventory.cpp
new file mode 100644
index 0000000..02a888d
--- /dev/null
+++ b/src/entity_manager/log_device_inventory.cpp
@@ -0,0 +1,116 @@
+#include "../utils.hpp"
+
+#include <systemd/sd-journal.h>
+
+#include <boost/container/flat_map.hpp>
+#include <nlohmann/json.hpp>
+
+#include <string>
+
+void logDeviceAdded(const nlohmann::json& record)
+{
+    if (!deviceHasLogging(record))
+    {
+        return;
+    }
+    auto findType = record.find("Type");
+    auto findAsset =
+        record.find("xyz.openbmc_project.Inventory.Decorator.Asset");
+
+    std::string model = "Unknown";
+    std::string type = "Unknown";
+    std::string sn = "Unknown";
+    std::string name = "Unknown";
+
+    if (findType != record.end())
+    {
+        type = findType->get<std::string>();
+    }
+    if (findAsset != record.end())
+    {
+        auto findModel = findAsset->find("Model");
+        auto findSn = findAsset->find("SerialNumber");
+        if (findModel != findAsset->end())
+        {
+            model = findModel->get<std::string>();
+        }
+        if (findSn != findAsset->end())
+        {
+            const std::string* getSn = findSn->get_ptr<const std::string*>();
+            if (getSn != nullptr)
+            {
+                sn = *getSn;
+            }
+            else
+            {
+                sn = findSn->dump();
+            }
+        }
+    }
+
+    auto findName = record.find("Name");
+    if (findName != record.end())
+    {
+        name = findName->get<std::string>();
+    }
+
+    sd_journal_send("MESSAGE=Inventory Added: %s", name.c_str(), "PRIORITY=%i",
+                    LOG_INFO, "REDFISH_MESSAGE_ID=%s",
+                    "OpenBMC.0.1.InventoryAdded",
+                    "REDFISH_MESSAGE_ARGS=%s,%s,%s", model.c_str(),
+                    type.c_str(), sn.c_str(), "NAME=%s", name.c_str(), NULL);
+}
+
+void logDeviceRemoved(const nlohmann::json& record)
+{
+    if (!deviceHasLogging(record))
+    {
+        return;
+    }
+    auto findType = record.find("Type");
+    auto findAsset =
+        record.find("xyz.openbmc_project.Inventory.Decorator.Asset");
+
+    std::string model = "Unknown";
+    std::string type = "Unknown";
+    std::string sn = "Unknown";
+    std::string name = "Unknown";
+
+    if (findType != record.end())
+    {
+        type = findType->get<std::string>();
+    }
+    if (findAsset != record.end())
+    {
+        auto findModel = findAsset->find("Model");
+        auto findSn = findAsset->find("SerialNumber");
+        if (findModel != findAsset->end())
+        {
+            model = findModel->get<std::string>();
+        }
+        if (findSn != findAsset->end())
+        {
+            const std::string* getSn = findSn->get_ptr<const std::string*>();
+            if (getSn != nullptr)
+            {
+                sn = *getSn;
+            }
+            else
+            {
+                sn = findSn->dump();
+            }
+        }
+    }
+
+    auto findName = record.find("Name");
+    if (findName != record.end())
+    {
+        name = findName->get<std::string>();
+    }
+
+    sd_journal_send("MESSAGE=Inventory Removed: %s", name.c_str(),
+                    "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s",
+                    "OpenBMC.0.1.InventoryRemoved",
+                    "REDFISH_MESSAGE_ARGS=%s,%s,%s", model.c_str(),
+                    type.c_str(), sn.c_str(), "NAME=%s", name.c_str(), NULL);
+}
diff --git a/src/entity_manager/log_device_inventory.hpp b/src/entity_manager/log_device_inventory.hpp
new file mode 100644
index 0000000..764f89b
--- /dev/null
+++ b/src/entity_manager/log_device_inventory.hpp
@@ -0,0 +1,22 @@
+/*
+// Copyright (c) 2018 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+#pragma once
+
+#include <nlohmann/json.hpp>
+
+void logDeviceAdded(const nlohmann::json& record);
+
+void logDeviceRemoved(const nlohmann::json& record);
diff --git a/src/entity_manager/meson.build b/src/entity_manager/meson.build
index c55a6a8..a0fb7ec 100644
--- a/src/entity_manager/meson.build
+++ b/src/entity_manager/meson.build
@@ -18,6 +18,7 @@
     'overlay.cpp',
     'topology.cpp',
     'utils.cpp',
+    'log_device_inventory.cpp',
     '../utils.cpp',
     'main.cpp',
     cpp_args: cpp_args_em,