remove phosphor-logging dependency
This commit removes pldm's dependency on phosphor-logging
and instead uses stdout and stdcerr for logging purpose.This is to
break the build time circular dependency between pldm and
phosphor-logging.
Change-Id: I8cffa3c99eb34efad5f186b3452a86ebadec2074
Signed-off-by: Sampa Misra <sampmisr@in.ibm.com>
diff --git a/libpldmresponder/pdr.hpp b/libpldmresponder/pdr.hpp
index c9df51f..87143a8 100644
--- a/libpldmresponder/pdr.hpp
+++ b/libpldmresponder/pdr.hpp
@@ -1,23 +1,22 @@
#pragma once
#include "effecters.hpp"
+#include "utils.hpp"
#include <stdint.h>
#include <filesystem>
#include <fstream>
#include <functional>
+#include <iostream>
#include <map>
#include <nlohmann/json.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
#include <string>
#include <vector>
#include <xyz/openbmc_project/Common/error.hpp>
#include "libpldm/platform.h"
-using namespace phosphor::logging;
using InternalFailure =
sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
namespace fs = std::filesystem;
@@ -109,8 +108,8 @@
std::ifstream jsonFile(path);
if (!jsonFile.is_open())
{
- log<level::INFO>("Error opening PDR JSON file",
- entry("PATH=%s", path.c_str()));
+ std::cout << "Error opening PDR JSON file, PATH=" << path.c_str()
+ << std::endl;
return {};
}
@@ -207,10 +206,10 @@
auto statesSize = set.value("size", 0);
if (!statesSize)
{
- log<level::ERR>(
- "Malformed PDR JSON - no state set info",
- entry("TYPE=%d", PLDM_STATE_EFFECTER_PDR));
- elog<InternalFailure>();
+ std::cerr
+ << "Malformed PDR JSON - no state set info, TYPE="
+ << PLDM_STATE_EFFECTER_PDR << "\n";
+ throw InternalFailure();
}
pdrSize += sizeof(state_effecter_possible_states) -
sizeof(bitfield8_t) +
@@ -295,12 +294,17 @@
catch (const InternalFailure& e)
{
}
+ catch (const Json::exception& e)
+ {
+ std::cerr << "Failed parsing PDR JSON file, TYPE= " << pdrType
+ << " ERROR=" << e.what() << "\n";
+ reportError("xyz.openbmc_project.bmc.pldm.InternalFailure");
+ }
catch (const std::exception& e)
{
- log<level::ERR>("Failed parsing PDR JSON file",
- entry("TYPE=%d", pdrType),
- entry("ERROR=%s", e.what()));
- report<InternalFailure>();
+ std::cerr << "Failed parsing PDR JSON file, TYPE= " << pdrType
+ << " ERROR=" << e.what() << "\n";
+ reportError("xyz.openbmc_project.bmc.pldm.InternalFailure");
}
}
}