Move the control application to lg2
Update the logging API used for files in phosphor-fan-presence/control
from the older phosphor::logging::log to the more recent lg2::log.
Tested:
* Verified journal traces worked correctly in simulation.
* Modified json to force various property errors and verified
correct key/value pairs in the journalctl output.
Change-Id: If1ac33b90abe2a9baae6f3cc788863bd514fa80e
Signed-off-by: Anwaar Hadi <anwaar.hadi@ibm.com>
diff --git a/control/json/config_base.hpp b/control/json/config_base.hpp
index a7b47b8..c521c9f 100644
--- a/control/json/config_base.hpp
+++ b/control/json/config_base.hpp
@@ -16,7 +16,7 @@
#pragma once
#include <nlohmann/json.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <vector>
@@ -24,7 +24,6 @@
{
using json = nlohmann::json;
-using namespace phosphor::logging;
using PropertyVariantType =
std::variant<bool, int32_t, int64_t, double, std::string>;
@@ -135,10 +134,9 @@
return *stringPtr;
}
- log<level::ERR>(
- "Unsupported data type for JSON object's value",
- entry("JSON_ENTRY=%s", object.dump().c_str()),
- entry("SUPPORTED_TYPES=%s", "{bool, int, double, string}"));
+ lg2::error(
+ "Unsupported data type for JSON object's value. Supported Types are 'bool, int, double, string'",
+ "JSON_ENTRY", object.dump());
throw std::runtime_error(
"Unsupported data type for JSON object's value");
}
@@ -165,8 +163,8 @@
if (!jsonObj.contains("name"))
{
// Log error on missing configuration object's name
- log<level::ERR>("Missing required configuration object's name",
- entry("JSON=%s", jsonObj.dump().c_str()));
+ lg2::error("Missing required configuration object's name", "JSON",
+ jsonObj.dump());
throw std::runtime_error(
"Missing required configuration object's name");
}