Add ability to disable device logging

Drive logic is too complicated, so it'll be handled
in a different daemon, add ability to disable logging
in EM.

Tested: No more logs

Change-Id: I55bd66df1eda9434b9ad9f98fd576d2073db0227
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/configurations/NVME P4000.json b/configurations/NVME P4000.json
index da8dacc..9c1cb70 100644
--- a/configurations/NVME P4000.json
+++ b/configurations/NVME P4000.json
@@ -40,6 +40,7 @@
             "Type": "NVME1000"
         }
     ],
+    "Logging": "Off",
     "Name": "NVMe $index",
     "Probe": "xyz.openbmc_project.FruDevice({'PRODUCT_PRODUCT_NAME': 'P\\d{4}\\w?'})",
     "Type": "NVMe",
diff --git a/include/EntityManager.hpp b/include/EntityManager.hpp
index 524fa5d..1b247d5 100644
--- a/include/EntityManager.hpp
+++ b/include/EntityManager.hpp
@@ -68,6 +68,10 @@
 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");
@@ -110,6 +114,10 @@
 
 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");
diff --git a/include/Utils.hpp b/include/Utils.hpp
index 58d4d42..d3e731f 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -129,4 +129,21 @@
     const boost::container::flat_map<std::string, BasicVariantType>&
         foundDevice,
     const size_t foundDeviceIdx,
-    const std::optional<std::string>& replaceStr = std::nullopt);
\ No newline at end of file
+    const std::optional<std::string>& replaceStr = std::nullopt);
+
+inline bool deviceHasLogging(const nlohmann::json& json)
+{
+    auto logging = json.find("Logging");
+    if (logging != json.end())
+    {
+        auto ptr = logging->get_ptr<const std::string*>();
+        if (ptr)
+        {
+            if (*ptr == "Off")
+            {
+                return false;
+            }
+        }
+    }
+    return true;
+}