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/dbus_impl_requester.cpp b/dbus_impl_requester.cpp
index ec0fc53..38ddb44 100644
--- a/dbus_impl_requester.cpp
+++ b/dbus_impl_requester.cpp
@@ -2,10 +2,9 @@
#include "xyz/openbmc_project/Common/error.hpp"
-#include <phosphor-logging/elog-errors.hpp>
+#include <iostream>
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
-using namespace phosphor::logging;
namespace pldm
{
@@ -27,7 +26,7 @@
}
catch (const std::runtime_error& e)
{
- elog<TooManyResources>();
+ throw TooManyResources();
}
return id;
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index b52b674..d815ce4 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -8,10 +8,9 @@
#include <chrono>
#include <ctime>
#include <filesystem>
+#include <iostream>
#include <memory>
#include <numeric>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
#include <stdexcept>
#include <string>
#include <variant>
@@ -28,7 +27,6 @@
namespace pldm
{
-using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
using EpochTimeUS = uint64_t;
using BIOSTableRow = std::vector<uint8_t>;
@@ -140,8 +138,8 @@
catch (std::exception& e)
{
- log<level::ERR>("Error getting time", entry("PATH=%s", hostTimePath),
- entry("TIME INTERACE=%s", timeInterface));
+ std::cerr << "Error getting time, PATH=" << hostTimePath
+ << " TIME INTERACE=" << timeInterface << "\n";
encode_get_date_time_resp(request->hdr.instance_id, PLDM_ERROR, seconds,
minutes, hours, day, month, year,
@@ -244,10 +242,9 @@
table.data(), table.size(), name.c_str());
if (stringEntry == nullptr)
{
- log<level::ERR>("Reached end of BIOS string table,did not find the "
- "handle for the string",
- entry("STRING=%s", name.c_str()));
- elog<InternalFailure>();
+ std::cerr << "Reached end of BIOS string table,did not find the "
+ << "handle for the string, STRING=" << name.c_str() << "\n";
+ throw InternalFailure();
}
return pldm_bios_table_string_entry_decode_handle(stringEntry);
@@ -270,9 +267,9 @@
std::string name;
if (stringEntry == nullptr)
{
- log<level::ERR>("Reached end of BIOS string table,did not find "
- "string name for handle",
- entry("STRING_HANDLE=%d", stringHdl));
+ std::cerr << "Reached end of BIOS string table,did not find "
+ << "string name for handle, STRING_HANDLE=" << stringHdl
+ << "\n";
}
auto strLength =
pldm_bios_table_string_entry_decode_string_length(stringEntry);
@@ -314,8 +311,8 @@
}
catch (InternalFailure& e)
{
- log<level::ERR>("Exception fetching handle for the string",
- entry("STRING=%s", currVal.c_str()));
+ std::cerr << "Exception fetching handle for the string, STRING="
+ << currVal.c_str() << "\n";
continue;
}
@@ -379,8 +376,8 @@
}
catch (InternalFailure& e)
{
- log<level::ERR>("Could not find handle for BIOS string",
- entry("ATTRIBUTE=%s", key.c_str()));
+ std::cerr << "Could not find handle for BIOS string, ATTRIBUTE="
+ << key.c_str() << "\n";
continue;
}
bool readOnly = (std::get<0>(value));
@@ -401,8 +398,8 @@
}
catch (InternalFailure& e)
{
- log<level::ERR>("Could not find handle for BIOS string",
- entry("STRING=%s", elem.c_str()));
+ std::cerr << "Could not find handle for BIOS string, STRING="
+ << elem.c_str() << "\n";
continue;
}
}
@@ -437,9 +434,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>("getAttrValue returned error for attribute",
- entry("NAME=%s", attrName.c_str()),
- entry("ERROR=%s", e.what()));
+ std::cerr << "getAttrValue returned error for attribute, NAME="
+ << attrName.c_str() << " ERROR=" << e.what() << "\n";
return;
}
uint8_t pv_num =
@@ -487,8 +483,8 @@
}
catch (InternalFailure& e)
{
- log<level::ERR>("Could not find handle for BIOS string",
- entry("ATTRIBUTE=%s", key.c_str()));
+ std::cerr << "Could not find handle for BIOS string, ATTRIBUTE="
+ << key.c_str() << "\n";
continue;
}
@@ -523,9 +519,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>("getAttrValue returned error for attribute",
- entry("NAME=%s", attrName.c_str()),
- entry("ERROR=%s", e.what()));
+ std::cerr << "getAttrValue returned error for attribute, NAME="
+ << attrName.c_str() << " ERROR=" << e.what() << "\n";
return;
}
auto entryLength =
@@ -563,8 +558,8 @@
}
catch (InternalFailure& e)
{
- log<level::ERR>("Could not find handle for BIOS string",
- entry("ATTRIBUTE=%s", key.c_str()));
+ std::cerr << "Could not find handle for BIOS string, ATTRIBUTE="
+ << key.c_str() << "\n";
continue;
}
@@ -596,9 +591,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>("Failed to get attribute value",
- entry("NAME=%s", attrName.c_str()),
- entry("ERROR=%s", e.what()));
+ std::cerr << "Failed to get attribute value, NAME=" << attrName.c_str()
+ << " ERROR=" << e.what() << "\n";
return;
}
auto entryLength = pldm_bios_table_attr_value_entry_encode_integer_length();
@@ -628,8 +622,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>("handler fails when traversing BIOSAttrTable",
- entry("ERROR=%s", e.what()));
+ std::cerr << "handler fails when traversing BIOSAttrTable, ERROR="
+ << e.what() << "\n";
}
pldm_bios_table_iter_next(iter.get());
}
@@ -733,8 +727,8 @@
auto attrName = findStringName(attrEntry->string_handle, BIOSStringTable);
if (attrName.empty())
{
- log<level::ERR>("invalid string handle",
- entry("STRING_HANDLE=%d", attrEntry->string_handle));
+ std::cerr << "invalid string handle, STRING_HANDLE="
+ << attrEntry->string_handle << "\n";
return;
}
diff --git a/libpldmresponder/bios_parser.cpp b/libpldmresponder/bios_parser.cpp
index a80771b..86c07c6 100644
--- a/libpldmresponder/bios_parser.cpp
+++ b/libpldmresponder/bios_parser.cpp
@@ -4,9 +4,9 @@
#include <filesystem>
#include <fstream>
+#include <iostream>
#include <nlohmann/json.hpp>
#include <optional>
-#include <phosphor-logging/log.hpp>
#include "libpldm/bios_table.h"
@@ -15,7 +15,6 @@
using Json = nlohmann::json;
namespace fs = std::filesystem;
-using namespace phosphor::logging;
const std::vector<Json> emptyJsonList{};
const Json emptyJson{};
@@ -53,8 +52,8 @@
std::ifstream jsonFile(filePath);
if (!jsonFile.is_open())
{
- log<level::ERR>("BIOS config file does not exist",
- entry("FILE=%s", filePath.c_str()));
+ std::cerr << "BIOS config file does not exist, FILE="
+ << filePath.c_str() << "\n";
rc = -1;
}
else
@@ -62,8 +61,8 @@
fileData = Json::parse(jsonFile, nullptr, false);
if (fileData.is_discarded())
{
- log<level::ERR>("Parsing config file failed",
- entry("FILE=%s", filePath.c_str()));
+ std::cerr << "Parsing config file failed, FILE=" << filePath.c_str()
+ << "\n";
rc = -1;
}
}
@@ -154,8 +153,8 @@
}
else
{
- log<level::ERR>("Unknown D-Bus property type",
- entry("TYPE=%s", type.c_str()));
+ std::cerr << "Unknown D-Bus property type, TYPE=" << type.c_str()
+ << "\n";
}
valueMap.emplace(value, pv[pos]);
@@ -291,9 +290,8 @@
auto iter = strTypeMap.find(strTypeTmp);
if (iter == strTypeMap.end())
{
- log<level::ERR>("Wrong string type",
- entry("STRING_TYPE=%s", strTypeTmp.c_str()),
- entry("ATTRIBUTE_NAME=%s", attr.c_str()));
+ std::cerr << "Wrong string type, STRING_TYPE=" << strTypeTmp.c_str()
+ << " ATTRIBUTE_NAME=" << attr.c_str() << "\n";
return -1;
}
uint8_t strType = iter->second;
@@ -313,13 +311,12 @@
auto rc = pldm_bios_table_attr_entry_string_info_check(&info, &errmsg);
if (rc != PLDM_SUCCESS)
{
- log<level::ERR>("Wrong filed for string attribute",
- entry("ATTRIBUTE_NAME=%s", attr.c_str()),
- entry("ERRMSG=%s", errmsg),
- entry("MINIMUM_STRING_LENGTH=%u", minStrLen),
- entry("MAXIMUM_STRING_LENGTH=%u", maxStrLen),
- entry("DEFAULT_STRING_LENGTH=%u", defaultStrLen),
- entry("DEFAULT_STRING=%s", defaultStr.data()));
+ std::cerr << "Wrong filed for string attribute, ATTRIBUTE_NAME="
+ << attr.c_str() << " ERRMSG=" << errmsg
+ << " MINIMUM_STRING_LENGTH=" << minStrLen
+ << " MAXIMUM_STRING_LENGTH=" << maxStrLen
+ << " DEFAULT_STRING_LENGTH=" << defaultStrLen
+ << " DEFAULT_STRING=" << defaultStr.data() << "\n";
return -1;
}
@@ -379,13 +376,12 @@
auto rc = pldm_bios_table_attr_entry_integer_info_check(&info, &errmsg);
if (rc != PLDM_SUCCESS)
{
- log<level::ERR>("Wrong filed for integer attribute",
- entry("ATTRIBUTE_NAME=%s", attr.c_str()),
- entry("ERRMSG=%s", errmsg),
- entry("LOWER_BOUND=%llu", lowerBound),
- entry("UPPER_BOUND=%llu", upperBound),
- entry("DEFAULT_VALUE=%llu", defaultValue),
- entry("SCALAR_INCREMENT=%lu", scalarIncrement));
+ std::cerr << "Wrong filed for integer attribute, ATTRIBUTE_NAME="
+ << attr.c_str() << " ERRMSG=" << errmsg
+ << " LOWER_BOUND=" << lowerBound
+ << " UPPER_BOUND=" << upperBound
+ << " DEFAULT_VALUE=" << defaultValue
+ << " SCALAR_INCREMENT=" << scalarIncrement << "\n";
return -1;
}
@@ -459,11 +455,11 @@
}
else
{
- log<level::ERR>(
- "Invalid dbus config",
- entry("OBJPATH=%s", dBusMap->objectPath.c_str()),
- entry("INTERFACE=%s", dBusMap->interface.c_str()),
- entry("PROPERTY_NAME=%s", dBusMap->propertyName.c_str()));
+ std::cerr << "Invalid dbus config, OBJPATH="
+ << dBusMap->objectPath.c_str()
+ << " INTERFACE=" << dBusMap->interface.c_str()
+ << " PROPERTY_NAME=" << dBusMap->propertyName.c_str()
+ << "\n";
}
}
lookup.emplace(attrName, dBusMap);
@@ -492,8 +488,8 @@
fs::path dir(dirPath);
if (!fs::exists(dir) || fs::is_empty(dir))
{
- log<level::ERR>("BIOS config directory does not exist or empty",
- entry("DIR=%s", dirPath));
+ std::cerr << "BIOS config directory does not exist or empty, DIR="
+ << dirPath << "\n";
return -1;
}
for (auto jsonName : BIOSConfigFiles)
@@ -513,8 +509,8 @@
}
if (BIOSStrings.empty())
{ // means there is no attribute
- log<level::ERR>("No attribute is found in the config directory",
- entry("DIR=%s", dirPath));
+ std::cerr << "No attribute is found in the config directory, DIR="
+ << dirPath << "\n";
return -1;
}
return 0;
diff --git a/libpldmresponder/meson.build b/libpldmresponder/meson.build
index 8ad31d4..2fc0f76 100644
--- a/libpldmresponder/meson.build
+++ b/libpldmresponder/meson.build
@@ -1,6 +1,5 @@
deps = [
dependency('phosphor-dbus-interfaces'),
- dependency('phosphor-logging'),
dependency('sdbusplus'),
libpldm
]
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");
}
}
}
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 50237cf..1d6d042 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -8,7 +8,6 @@
namespace platform
{
-using namespace phosphor::logging;
using namespace pldm::responder::effecter::dbus_mapping;
Response Handler::getPDR(const pldm_msg* request, size_t payloadLength)
@@ -69,8 +68,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>("Error accessing PDR", entry("HANDLE=%d", recordHandle),
- entry("ERROR=%s", e.what()));
+ std::cerr << "Error accessing PDR, HANDLE=" << recordHandle
+ << " ERROR=" << e.what() << "\n";
encode_get_pdr_resp(request->hdr.instance_id, PLDM_ERROR,
nextRecordHandle, 0, PLDM_START, respSizeBytes,
recordData, 0, responsePtr);
diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index be48950..1c6c733 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -83,7 +83,6 @@
{PLDM_SYSTEM_POWER_STATE,
{{PLDM_OFF_SOFT_GRACEFUL,
"xyz.openbmc_project.State.Chassis.Transition.Off"s}}}};
- using namespace phosphor::logging;
using namespace pldm::responder::pdr;
using namespace pldm::responder::effecter::dbus_mapping;
@@ -116,11 +115,10 @@
pdr->possible_states);
if (compEffecterCnt > pdr->composite_effecter_count)
{
- log<level::ERR>(
- "The requester sent wrong composite effecter "
- "count for the effecter",
- entry("EFFECTER_ID=%d", effecterId),
- entry("COMP_EFF_CNT=%d", compEffecterCnt));
+ std::cerr
+ << "The requester sent wrong composite effecter"
+ << " count for the effecter, EFFECTER_ID=" << effecterId
+ << "COMP_EFF_CNT=" << compEffecterCnt << "\n";
return PLDM_ERROR_INVALID_DATA;
}
break;
@@ -142,22 +140,22 @@
stateNumToDbusProp.find(PLDM_BOOT_PROGRESS_STATE);
if (stateSet == stateNumToDbusProp.end())
{
- log<level::ERR>("Couldn't find D-Bus mapping for "
- "PLDM_BOOT_PROGRESS_STATE",
- entry("EFFECTER_ID=%d", effecterId));
+ std::cerr << "Couldn't find D-Bus mapping for "
+ << "PLDM_BOOT_PROGRESS_STATE, EFFECTER_ID="
+ << effecterId << "\n";
return PLDM_ERROR;
}
auto iter = stateSet->second.find(
stateField[currState].effecter_state);
if (iter == stateSet->second.end())
{
- log<level::ERR>(
- "Invalid state field passed or field not "
- "found for PLDM_BOOT_PROGRESS_STATE",
- entry("EFFECTER_ID=%d", effecterId),
- entry("FIELD=%d",
- stateField[currState].effecter_state),
- entry("OBJECT_PATH=%s", objPath.c_str()));
+ std::cerr << "Invalid state field passed or field not "
+ << "found for PLDM_BOOT_PROGRESS_STATE, "
+ "EFFECTER_ID="
+ << effecterId << " FIELD="
+ << stateField[currState].effecter_state
+ << " OBJECT_PATH=" << objPath.c_str()
+ << "\n";
return PLDM_ERROR_INVALID_DATA;
}
auto dbusProp = "OperatingSystemState";
@@ -172,11 +170,11 @@
}
catch (const std::exception& e)
{
- log<level::ERR>("Error setting property",
- entry("ERROR=%s", e.what()),
- entry("PROPERTY=%s", dbusProp),
- entry("INTERFACE=%s", dbusInterface),
- entry("PATH=%s", objPath.c_str()));
+ std::cerr
+ << "Error setting property, ERROR=" << e.what()
+ << " PROPERTY=" << dbusProp
+ << " INTERFACE=" << dbusInterface
+ << " PATH=" << objPath.c_str() << "\n";
return PLDM_ERROR;
}
return PLDM_SUCCESS;
@@ -187,22 +185,22 @@
stateNumToDbusProp.find(PLDM_SYSTEM_POWER_STATE);
if (stateSet == stateNumToDbusProp.end())
{
- log<level::ERR>("Couldn't find D-Bus mapping for "
- "PLDM_SYSTEM_POWER_STATE",
- entry("EFFECTER_ID=%d", effecterId));
+ std::cerr << "Couldn't find D-Bus mapping for "
+ << "PLDM_SYSTEM_POWER_STATE, EFFECTER_ID="
+ << effecterId << "\n";
return PLDM_ERROR;
}
auto iter = stateSet->second.find(
stateField[currState].effecter_state);
if (iter == stateSet->second.end())
{
- log<level::ERR>(
- "Invalid state field passed or field not "
- "found for PLDM_SYSTEM_POWER_STATE",
- entry("EFFECTER_ID=%d", effecterId),
- entry("FIELD=%d",
- stateField[currState].effecter_state),
- entry("OBJECT_PATH=%s", objPath.c_str()));
+ std::cerr << "Invalid state field passed or field not "
+ << "found for PLDM_SYSTEM_POWER_STATE, "
+ "EFFECTER_ID="
+ << effecterId << " FIELD="
+ << stateField[currState].effecter_state
+ << " OBJECT_PATH=" << objPath.c_str()
+ << "\n";
return PLDM_ERROR_INVALID_DATA;
}
auto dbusProp = "RequestedPowerTransition";
@@ -216,11 +214,11 @@
}
catch (const std::exception& e)
{
- log<level::ERR>("Error setting property",
- entry("ERROR=%s", e.what()),
- entry("PROPERTY=%s", dbusProp),
- entry("INTERFACE=%s", dbusInterface),
- entry("PATH=%s", objPath.c_str()));
+ std::cerr
+ << "Error setting property, ERROR=" << e.what()
+ << " PROPERTY=" << dbusProp
+ << " INTERFACE=" << dbusInterface
+ << " PATH=" << objPath.c_str() << "\n";
return PLDM_ERROR;
}
return PLDM_SUCCESS;
@@ -238,12 +236,11 @@
if (states->possible_states_size < bitfieldIndex ||
!(states->states[bitfieldIndex].byte & (1 << bit)))
{
- log<level::ERR>(
- "Invalid state set value",
- entry("EFFECTER_ID=%d", effecterId),
- entry("VALUE=%d", stateField[currState].effecter_state),
- entry("COMPOSITE_EFFECTER_ID=%d", currState),
- entry("DBUS_PATH=%c", paths[currState].c_str()));
+ std::cerr << "Invalid state set value, EFFECTER_ID="
+ << effecterId
+ << " VALUE=" << stateField[currState].effecter_state
+ << " COMPOSITE_EFFECTER_ID=" << currState
+ << " DBUS_PATH=" << paths[currState].c_str() << "\n";
rc = PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE;
break;
}
@@ -251,10 +248,9 @@
if (iter == effecterToDbusEntries.end())
{
uint16_t setId = states->state_set_id;
- log<level::ERR>(
- "Did not find the state set for the state effecter pdr ",
- entry("STATE=%d", setId),
- entry("EFFECTER_ID=%d", effecterId));
+ std::cerr << "Did not find the state set for the"
+ << " state effecter pdr, STATE=" << setId
+ << " EFFECTER_ID=" << effecterId << "\n";
rc = PLDM_PLATFORM_INVALID_STATE_VALUE;
break;
}
diff --git a/libpldmresponder/utils.cpp b/libpldmresponder/utils.cpp
index 766a183..8290675 100644
--- a/libpldmresponder/utils.cpp
+++ b/libpldmresponder/utils.cpp
@@ -6,14 +6,12 @@
#include <ctime>
#include <iostream>
#include <map>
-#include <phosphor-logging/log.hpp>
#include <stdexcept>
#include <string>
#include <vector>
namespace pldm
{
-using namespace phosphor::logging;
constexpr auto mapperBusName = "xyz.openbmc_project.ObjectMapper";
constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
@@ -39,14 +37,42 @@
}
catch (std::exception& e)
{
- log<level::ERR>("Error in mapper call", entry("ERROR=%s", e.what()),
- entry("PATH=%s", path.c_str()),
- entry("INTERFACE=%s", interface.c_str()));
+ std::cerr << "Error in mapper call, ERROR=" << e.what()
+ << " PATH=" << path.c_str()
+ << " INTERFACE=" << interface.c_str() << "\n";
throw;
}
return mapperResponse.begin()->first;
}
+void reportError(const char* errorMsg)
+{
+ static constexpr auto logObjPath = "/xyz/openbmc_project/logging";
+ static constexpr auto logInterface = "xyz.openbmc_project.Logging.Create";
+
+ static sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+
+ try
+ {
+ auto service = getService(bus, logObjPath, logInterface);
+ using namespace sdbusplus::xyz::openbmc_project::Logging::server;
+ auto severity =
+ sdbusplus::xyz::openbmc_project::Logging::server::convertForMessage(
+ sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level::
+ Error);
+ auto method = bus.new_method_call(service.c_str(), logObjPath,
+ logInterface, "Create");
+ std::map<std::string, std::string> addlData{};
+ method.append(errorMsg, severity, addlData);
+ bus.call_noreply(method);
+ }
+ catch (const std::exception& e)
+ {
+ std::cerr << "failed to make a d-bus call to create error log, ERROR="
+ << e.what() << "\n";
+ }
+}
+
namespace utils
{
diff --git a/libpldmresponder/utils.hpp b/libpldmresponder/utils.hpp
index f494291..453f6d9 100644
--- a/libpldmresponder/utils.hpp
+++ b/libpldmresponder/utils.hpp
@@ -5,11 +5,12 @@
#include <unistd.h>
#include <exception>
-#include <phosphor-logging/log.hpp>
+#include <iostream>
#include <sdbusplus/server.hpp>
#include <string>
#include <variant>
#include <vector>
+#include <xyz/openbmc_project/Logging/Entry/server.hpp>
#include "libpldm/base.h"
@@ -71,6 +72,12 @@
std::string getService(sdbusplus::bus::bus& bus, const std::string& path,
const std::string& interface);
+/**
+ * @brief creates an error log
+ * @param[in] errorMsg - the error message
+ */
+void reportError(const char* errorMsg);
+
/** @brief Convert any Decimal number to BCD
*
* @tparam[in] decimal - Decimal number
@@ -133,7 +140,6 @@
auto getDbusPropertyVariant(const char* objPath, const char* dbusProp,
const char* dbusInterface)
{
- using namespace phosphor::logging;
Variant value;
auto bus = sdbusplus::bus::new_default();
auto service = getService(bus, objPath, dbusInterface);
@@ -147,10 +153,10 @@
}
catch (const sdbusplus::exception::SdBusError& e)
{
- log<level::ERR>("dbus call expection", entry("OBJPATH=%s", objPath),
- entry("INTERFACE=%s", dbusInterface),
- entry("PROPERTY=%s", dbusProp),
- entry("EXPECTION=%s", e.what()));
+ std::cerr << "dbus call exception, OBJPATH=" << objPath
+ << " INTERFACE=" << dbusInterface
+ << " PROPERTY=" << dbusProp << " EXCEPTION=" << e.what()
+ << "\n";
}
return value;
}
diff --git a/oem/ibm/libpldmresponder/file_io.cpp b/oem/ibm/libpldmresponder/file_io.cpp
index be0c95b..6f65b97 100644
--- a/oem/ibm/libpldmresponder/file_io.cpp
+++ b/oem/ibm/libpldmresponder/file_io.cpp
@@ -15,23 +15,20 @@
#include <cstring>
#include <fstream>
+#include <iostream>
#include <memory>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
#include "libpldm/base.h"
namespace pldm
{
-using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
namespace responder
{
namespace fs = std::filesystem;
-using namespace phosphor::logging;
namespace dma
{
@@ -74,7 +71,7 @@
if (fd < 0)
{
rc = -errno;
- log<level::ERR>("Failed to open the XDMA device", entry("RC=%d", rc));
+ std::cerr << "Failed to open the XDMA device, RC=" << rc << "\n";
return rc;
}
@@ -86,7 +83,7 @@
if (MAP_FAILED == vgaMem)
{
rc = -errno;
- log<level::ERR>("Failed to mmap the XDMA device", entry("RC=%d", rc));
+ std::cerr << "Failed to mmap the XDMA device, RC=" << rc << "\n";
return rc;
}
@@ -108,10 +105,9 @@
if (static_cast<uint32_t>(stream.gcount()) != length)
{
- log<level::ERR>("mismatch between number of characters to read and "
- "the length read",
- entry("LENGTH=%d", length),
- entry("COUNT=%d", stream.gcount()));
+ std::cerr << "mismatch between number of characters to read and "
+ << "the length read, LENGTH=" << length
+ << " COUNT=" << stream.gcount() << "\n";
return -1;
}
}
@@ -125,10 +121,9 @@
if (rc < 0)
{
rc = -errno;
- log<level::ERR>("Failed to execute the DMA operation",
- entry("RC=%d", rc), entry("UPSTREAM=%d", upstream),
- entry("ADDRESS=%lld", address),
- entry("LENGTH=%d", length));
+ std::cerr << "Failed to execute the DMA operation, RC=" << rc
+ << " UPSTREAM=" << upstream << " ADDRESS=" << address
+ << " LENGTH=" << length << "\n";
return rc;
}
@@ -185,8 +180,8 @@
}
catch (std::exception& e)
{
- log<level::ERR>("File handle does not exist in the file table",
- entry("HANDLE=%d", fileHandle));
+ std::cerr << "File handle does not exist in the file table, HANDLE="
+ << fileHandle << "\n";
encode_rw_file_memory_resp(request->hdr.instance_id,
PLDM_READ_FILE_INTO_MEMORY,
PLDM_INVALID_FILE_HANDLE, 0, responsePtr);
@@ -195,7 +190,7 @@
if (!fs::exists(value.fsPath))
{
- log<level::ERR>("File does not exist", entry("HANDLE=%d", fileHandle));
+ std::cerr << "File does not exist, HANDLE=" << fileHandle << "\n";
encode_rw_file_memory_resp(request->hdr.instance_id,
PLDM_READ_FILE_INTO_MEMORY,
PLDM_INVALID_FILE_HANDLE, 0, responsePtr);
@@ -205,8 +200,8 @@
auto fileSize = fs::file_size(value.fsPath);
if (offset >= fileSize)
{
- log<level::ERR>("Offset exceeds file size", entry("OFFSET=%d", offset),
- entry("FILE_SIZE=%d", fileSize));
+ std::cerr << "Offset exceeds file size, OFFSET=" << offset
+ << " FILE_SIZE=" << fileSize << "\n";
encode_rw_file_memory_resp(request->hdr.instance_id,
PLDM_READ_FILE_INTO_MEMORY,
PLDM_DATA_OUT_OF_RANGE, 0, responsePtr);
@@ -220,8 +215,8 @@
if (length % dma::minSize)
{
- log<level::ERR>("Read length is not a multiple of DMA minSize",
- entry("LENGTH=%d", length));
+ std::cerr << "Read length is not a multiple of DMA minSize, LENGTH="
+ << length << "\n";
encode_rw_file_memory_resp(request->hdr.instance_id,
PLDM_READ_FILE_INTO_MEMORY,
PLDM_INVALID_READ_LENGTH, 0, responsePtr);
@@ -259,8 +254,8 @@
if (length % dma::minSize)
{
- log<level::ERR>("Write length is not a multiple of DMA minSize",
- entry("LENGTH=%d", length));
+ std::cerr << "Write length is not a multiple of DMA minSize, LENGTH="
+ << length << "\n";
encode_rw_file_memory_resp(request->hdr.instance_id,
PLDM_WRITE_FILE_FROM_MEMORY,
PLDM_INVALID_WRITE_LENGTH, 0, responsePtr);
@@ -277,8 +272,8 @@
}
catch (std::exception& e)
{
- log<level::ERR>("File handle does not exist in the file table",
- entry("HANDLE=%d", fileHandle));
+ std::cerr << "File handle does not exist in the file table, HANDLE="
+ << fileHandle << "\n";
encode_rw_file_memory_resp(request->hdr.instance_id,
PLDM_WRITE_FILE_FROM_MEMORY,
PLDM_INVALID_FILE_HANDLE, 0, responsePtr);
@@ -287,7 +282,7 @@
if (!fs::exists(value.fsPath))
{
- log<level::ERR>("File does not exist", entry("HANDLE=%d", fileHandle));
+ std::cerr << "File does not exist, HANDLE=" << fileHandle << "\n";
encode_rw_file_memory_resp(request->hdr.instance_id,
PLDM_WRITE_FILE_FROM_MEMORY,
PLDM_INVALID_FILE_HANDLE, 0, responsePtr);
@@ -297,8 +292,8 @@
auto fileSize = fs::file_size(value.fsPath);
if (offset >= fileSize)
{
- log<level::ERR>("Offset exceeds file size", entry("OFFSET=%d", offset),
- entry("FILE_SIZE=%d", fileSize));
+ std::cerr << "Offset exceeds file size, OFFSET=" << offset
+ << " FILE_SIZE=" << fileSize << "\n";
encode_rw_file_memory_resp(request->hdr.instance_id,
PLDM_WRITE_FILE_FROM_MEMORY,
PLDM_DATA_OUT_OF_RANGE, 0, responsePtr);
@@ -402,8 +397,8 @@
}
catch (std::exception& e)
{
- log<level::ERR>("File handle does not exist in the file table",
- entry("HANDLE=%d", fileHandle));
+ std::cerr << "File handle does not exist in the file table, HANDLE="
+ << fileHandle << "\n";
encode_read_file_resp(request->hdr.instance_id,
PLDM_INVALID_FILE_HANDLE, length, responsePtr);
return response;
@@ -411,7 +406,7 @@
if (!fs::exists(value.fsPath))
{
- log<level::ERR>("File does not exist", entry("HANDLE=%d", fileHandle));
+ std::cerr << "File does not exist, HANDLE=" << fileHandle << "\n";
encode_read_file_resp(request->hdr.instance_id,
PLDM_INVALID_FILE_HANDLE, length, responsePtr);
return response;
@@ -420,8 +415,8 @@
auto fileSize = fs::file_size(value.fsPath);
if (offset >= fileSize)
{
- log<level::ERR>("Offset exceeds file size", entry("OFFSET=%d", offset),
- entry("FILE_SIZE=%d", fileSize));
+ std::cerr << "Offset exceeds file size, OFFSET=" << offset
+ << " FILE_SIZE=" << fileSize << "\n";
encode_read_file_resp(request->hdr.instance_id, PLDM_DATA_OUT_OF_RANGE,
length, responsePtr);
return response;
@@ -483,8 +478,8 @@
}
catch (std::exception& e)
{
- log<level::ERR>("File handle does not exist in the file table",
- entry("HANDLE=%d", fileHandle));
+ std::cerr << "File handle does not exist in the file table, HANDLE="
+ << fileHandle << "\n";
encode_write_file_resp(request->hdr.instance_id,
PLDM_INVALID_FILE_HANDLE, 0, responsePtr);
return response;
@@ -492,7 +487,7 @@
if (!fs::exists(value.fsPath))
{
- log<level::ERR>("File does not exist", entry("HANDLE=%d", fileHandle));
+ std::cerr << "File does not exist, HANDLE=" << fileHandle << "\n";
encode_write_file_resp(request->hdr.instance_id,
PLDM_INVALID_FILE_HANDLE, 0, responsePtr);
return response;
@@ -501,8 +496,8 @@
auto fileSize = fs::file_size(value.fsPath);
if (offset >= fileSize)
{
- log<level::ERR>("Offset exceeds file size", entry("OFFSET=%d", offset),
- entry("FILE_SIZE=%d", fileSize));
+ std::cerr << "Offset exceeds file size, OFFSET=" << offset
+ << " FILE_SIZE=" << fileSize << "\n";
encode_write_file_resp(request->hdr.instance_id, PLDM_DATA_OUT_OF_RANGE,
0, responsePtr);
return response;
@@ -553,8 +548,8 @@
}
if (length % dma::minSize)
{
- log<level::ERR>("Length is not a multiple of DMA minSize",
- entry("LENGTH=%d", length));
+ std::cerr << "Length is not a multiple of DMA minSize, LENGTH="
+ << length << "\n";
encode_rw_file_by_type_memory_resp(request->hdr.instance_id, cmd,
PLDM_INVALID_WRITE_LENGTH, 0,
responsePtr);
@@ -568,7 +563,7 @@
}
catch (const InternalFailure& e)
{
- log<level::ERR>("unknown file type ", entry("TYPE=%d", fileType));
+ std::cerr << "unknown file type, TYPE=" << fileType << "\n";
encode_rw_file_by_type_memory_resp(request->hdr.instance_id, cmd,
PLDM_INVALID_FILE_TYPE, 0,
responsePtr);
@@ -630,7 +625,7 @@
}
catch (const InternalFailure& e)
{
- log<level::ERR>("unknown file type", entry("TYPE=%d", fileType));
+ std::cerr << "unknown file type, TYPE=" << fileType << "\n";
encode_rw_file_by_type_resp(request->hdr.instance_id,
PLDM_READ_FILE_BY_TYPE,
PLDM_INVALID_FILE_TYPE, 0, responsePtr);
diff --git a/oem/ibm/libpldmresponder/file_io_by_type.cpp b/oem/ibm/libpldmresponder/file_io_by_type.cpp
index efe8e37..7a95a6d 100644
--- a/oem/ibm/libpldmresponder/file_io_by_type.cpp
+++ b/oem/ibm/libpldmresponder/file_io_by_type.cpp
@@ -13,8 +13,7 @@
#include <exception>
#include <filesystem>
#include <fstream>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
+#include <iostream>
#include <vector>
#include <xyz/openbmc_project/Logging/Entry/server.hpp>
@@ -26,7 +25,6 @@
namespace responder
{
-using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
int FileHandler::transferFileData(const fs::path& path, bool upstream,
@@ -37,17 +35,15 @@
{
if (!fs::exists(path))
{
- log<level::ERR>("File does not exist",
- entry("PATH=%s", path.c_str()));
+ std::cerr << "File does not exist. PATH=" << path.c_str() << "\n";
return PLDM_INVALID_FILE_HANDLE;
}
size_t fileSize = fs::file_size(path);
if (offset >= fileSize)
{
- log<level::ERR>("Offset exceeds file size",
- entry("OFFSET=%d", offset),
- entry("FILE_SIZE=%d", fileSize));
+ std::cerr << "Offset exceeds file size, OFFSET=" << offset
+ << " FILE_SIZE=" << fileSize << "\n";
return PLDM_DATA_OUT_OF_RANGE;
}
if (offset + length > fileSize)
@@ -97,7 +93,7 @@
}
default:
{
- elog<InternalFailure>();
+ throw InternalFailure();
break;
}
}
@@ -109,16 +105,16 @@
{
if (!fs::exists(filePath))
{
- log<level::ERR>("File does not exist", entry("HANDLE=%d", fileHandle),
- entry("PATH=%s", filePath.c_str()));
+ std::cerr << "File does not exist, HANDLE=" << fileHandle
+ << " PATH=" << filePath.c_str() << "\n";
return PLDM_INVALID_FILE_HANDLE;
}
size_t fileSize = fs::file_size(filePath);
if (offset >= fileSize)
{
- log<level::ERR>("Offset exceeds file size", entry("OFFSET=%d", offset),
- entry("FILE_SIZE=%d", fileSize));
+ std::cerr << "Offset exceeds file size, OFFSET=" << offset
+ << " FILE_SIZE=" << fileSize << "\n";
return PLDM_DATA_OUT_OF_RANGE;
}
@@ -138,7 +134,7 @@
stream.read(filePos, length);
return PLDM_SUCCESS;
}
- log<level::ERR>("Unable to read file", entry("FILE=%s", filePath.c_str()));
+ std::cerr << "Unable to read file, FILE=" << filePath.c_str() << "\n";
return PLDM_ERROR;
}
diff --git a/oem/ibm/libpldmresponder/file_io_type_pel.cpp b/oem/ibm/libpldmresponder/file_io_type_pel.cpp
index a5fa49a..c919c27 100644
--- a/oem/ibm/libpldmresponder/file_io_type_pel.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_pel.cpp
@@ -11,6 +11,7 @@
#include <exception>
#include <filesystem>
+#include <iostream>
#include <sdbusplus/server.hpp>
#include <vector>
#include <xyz/openbmc_project/Logging/Entry/server.hpp>
@@ -23,8 +24,6 @@
namespace responder
{
-using namespace phosphor::logging;
-
int PelHandler::readIntoMemory(uint32_t /*offset*/, uint32_t& /*length*/,
uint64_t /*address*/)
{
@@ -44,8 +43,8 @@
int fd = mkstemp(tmpFile);
if (fd == -1)
{
- log<level::ERR>("failed to create a temporary pel",
- entry("ERROR=%d", errno));
+ std::cerr << "failed to create a temporary pel, ERROR=" << errno
+ << "\n";
return PLDM_ERROR;
}
close(fd);
@@ -86,8 +85,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>("failed to make a d-bus call to PEL daemon",
- entry("ERROR=%s", e.what()));
+ std::cerr << "failed to make a d-bus call to PEL daemon, ERROR="
+ << e.what() << "\n";
return PLDM_ERROR;
}
diff --git a/oem/ibm/libpldmresponder/file_table.cpp b/oem/ibm/libpldmresponder/file_table.cpp
index 9264f21..4b3198c 100644
--- a/oem/ibm/libpldmresponder/file_table.cpp
+++ b/oem/ibm/libpldmresponder/file_table.cpp
@@ -2,7 +2,7 @@
#include <boost/crc.hpp>
#include <fstream>
-#include <phosphor-logging/log.hpp>
+#include <iostream>
namespace pldm
{
@@ -10,22 +10,21 @@
namespace filetable
{
-using namespace phosphor::logging;
-
FileTable::FileTable(const std::string& fileTableConfigPath)
{
std::ifstream jsonFile(fileTableConfigPath);
if (!jsonFile.is_open())
{
- log<level::ERR>("File table config file does not exist",
- entry("FILE=%s", fileTableConfigPath.c_str()));
+ std::cerr << "File table config file does not exist, FILE="
+ << fileTableConfigPath.c_str() << "\n";
return;
}
auto data = Json::parse(jsonFile, nullptr, false);
if (data.is_discarded())
{
- log<level::ERR>("Parsing config file failed");
+ std::cerr << "Parsing config file failed"
+ << "\n";
return;
}
diff --git a/pldmd.cpp b/pldmd.cpp
index 1b37726..6394b4d 100644
--- a/pldmd.cpp
+++ b/pldmd.cpp
@@ -19,7 +19,6 @@
#include <iomanip>
#include <iostream>
#include <iterator>
-#include <phosphor-logging/log.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/source/io.hpp>
#include <sstream>
@@ -38,7 +37,6 @@
constexpr uint8_t MCTP_MSG_TYPE_PLDM = 1;
using namespace pldm::responder;
-using namespace phosphor::logging;
using namespace pldm;
using namespace sdeventplus;
using namespace sdeventplus::source;
@@ -55,7 +53,7 @@
requestMsg.data() + sizeof(eid) + sizeof(type));
if (PLDM_SUCCESS != unpack_pldm_header(hdr, &hdrFields))
{
- log<level::ERR>("Empty PLDM request header");
+ std::cerr << "Empty PLDM request header \n";
}
else if (PLDM_RESPONSE != hdrFields.msg_type)
{
@@ -80,7 +78,7 @@
auto result = pack_pldm_header(&header, responseHdr);
if (PLDM_SUCCESS != result)
{
- log<level::ERR>("Failed adding response header");
+ std::cerr << "Failed adding response header \n";
}
response.insert(response.end(), completion_code);
}
@@ -104,7 +102,7 @@
<< " ";
}
}
- log<level::INFO>(tempStream.str().c_str());
+ std::cout << tempStream.str().c_str() << std::endl;
}
void optionUsage(void)
@@ -161,8 +159,7 @@
if (-1 == sockfd)
{
returnCode = -errno;
- log<level::ERR>("Failed to create the socket",
- entry("RC=%d", returnCode));
+ std::cerr << "Failed to create the socket, RC= " << returnCode << "\n";
exit(EXIT_FAILURE);
}
@@ -179,8 +176,8 @@
if (-1 == result)
{
returnCode = -errno;
- log<level::ERR>("Failed to connect to the socket",
- entry("RC=%d", returnCode));
+ std::cerr << "Failed to connect to the socket, RC= " << returnCode
+ << "\n";
exit(EXIT_FAILURE);
}
@@ -188,8 +185,8 @@
if (-1 == result)
{
returnCode = -errno;
- log<level::ERR>("Failed to send message type as pldm to mctp",
- entry("RC=%d", returnCode));
+ std::cerr << "Failed to send message type as pldm to mctp, RC= "
+ << returnCode << "\n";
exit(EXIT_FAILURE);
}
@@ -215,13 +212,12 @@
ssize_t peekedLength = recv(fd, nullptr, 0, MSG_PEEK | MSG_TRUNC);
if (0 == peekedLength)
{
- log<level::ERR>("Socket has been closed");
+ std::cerr << "Socket has been closed \n";
}
else if (peekedLength <= -1)
{
returnCode = -errno;
- log<level::ERR>("recv system call failed",
- entry("RC=%d", returnCode));
+ std::cerr << "recv system call failed, RC= " << returnCode << "\n";
}
else
{
@@ -232,17 +228,14 @@
{
if (verbose)
{
- log<level::INFO>("Received Msg ",
- entry("LENGTH=%zu", recvDataLength),
- entry("EID=0x%02x", requestMsg[0]),
- entry("TYPE=0x%02x", requestMsg[1]));
+ std::cout << "Received Msg" << std::endl;
printBuffer(requestMsg);
}
if (MCTP_MSG_TYPE_PLDM != requestMsg[1])
{
// Skip this message and continue.
- log<level::ERR>("Encountered Non-PLDM type message",
- entry("TYPE=0x%02x", requestMsg[1]));
+ std::cerr << "Encountered Non-PLDM type message"
+ << "\n";
}
else
{
@@ -253,7 +246,7 @@
{
if (verbose)
{
- log<level::INFO>("Sending Msg ");
+ std::cout << "Sending Msg" << std::endl;
printBuffer(response);
}
@@ -270,17 +263,18 @@
if (-1 == result)
{
returnCode = -errno;
- log<level::ERR>("sendto system call failed",
- entry("RC=%d", returnCode));
+ std::cerr << "sendto system call failed, RC= "
+ << returnCode << "\n";
}
}
}
}
else
{
- log<level::ERR>("Failure to read peeked length packet",
- entry("PEEKED_LENGTH=%zu", peekedLength),
- entry("READ_LENGTH=%zu", recvDataLength));
+ std::cerr
+ << "Failure to read peeked length packet. peekedLength= "
+ << peekedLength << " recvDataLength=" << recvDataLength
+ << "\n";
}
}
};
@@ -295,8 +289,7 @@
if (-1 == result)
{
returnCode = -errno;
- log<level::ERR>("Failed to shutdown the socket",
- entry("RC=%d", returnCode));
+ std::cerr << "Failed to shutdown the socket, RC=" << returnCode << "\n";
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
diff --git a/test/libpldmresponder_pdr_state_effecter_test.cpp b/test/libpldmresponder_pdr_state_effecter_test.cpp
index c55feb0..e758f63 100644
--- a/test/libpldmresponder_pdr_state_effecter_test.cpp
+++ b/test/libpldmresponder_pdr_state_effecter_test.cpp
@@ -103,5 +103,7 @@
Repo& pdrRepo = get("./pdr_jsons/state_effecter/good");
ASSERT_EQ(pdrRepo.numEntries(), 2);
pdrRepo.makeEmpty();
- ASSERT_THROW(get("./pdr_jsons/state_effecter/malformed"), std::exception);
+ ASSERT_THROW(pldm::responder::pdr::internal::readJson(
+ "./pdr_jsons/state_effecter/malformed"),
+ std::exception);
}
diff --git a/test/libpldmresponder_platform_test.cpp b/test/libpldmresponder_platform_test.cpp
index 88a6eb4..208edc3 100644
--- a/test/libpldmresponder_platform_test.cpp
+++ b/test/libpldmresponder_platform_test.cpp
@@ -160,13 +160,13 @@
sizeof(uint16_t);
pldm_pdr_hdr* hdr = reinterpret_cast<pldm_pdr_hdr*>(start);
uint32_t intType = hdr->type;
- std::cerr << "PDR next record handle " << handle << std::endl;
- std::cerr << "PDR type " << intType << std::endl;
+ std::cerr << "PDR next record handle " << handle << "\n";
+ std::cerr << "PDR type " << intType << "\n";
if (hdr->type == PLDM_STATE_EFFECTER_PDR)
{
pldm_state_effecter_pdr* pdr =
reinterpret_cast<pldm_state_effecter_pdr*>(start);
- std::cerr << "PDR entity type " << pdr->entity_type << std::endl;
+ std::cerr << "PDR entity type " << pdr->entity_type << "\n";
if (pdr->entity_type == 100)
{
found = true;
diff --git a/test/meson.build b/test/meson.build
index 4019cde..a9cdd94 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -51,7 +51,6 @@
gmock,
pldmd,
dependency('phosphor-dbus-interfaces'),
- dependency('phosphor-logging'),
dependency('sdbusplus')]),
workdir: meson.current_source_dir())
endforeach
diff --git a/tool/pldm_base_cmd.cpp b/tool/pldm_base_cmd.cpp
index 601635c..f0653e5 100644
--- a/tool/pldm_base_cmd.cpp
+++ b/tool/pldm_base_cmd.cpp
@@ -57,7 +57,7 @@
if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
{
std::cerr << "Response Message Error: "
- << "rc=" << rc << ",cc=" << (int)cc << std::endl;
+ << "rc=" << rc << ",cc=" << (int)cc << "\n";
return;
}
@@ -128,7 +128,7 @@
if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
{
std::cerr << "Response Message Error: "
- << "rc=" << rc << ",cc=" << (int)cc << std::endl;
+ << "rc=" << rc << ",cc=" << (int)cc << "\n";
return;
}
char buffer[16] = {0};
diff --git a/tool/pldm_cmd_helper.cpp b/tool/pldm_cmd_helper.cpp
index b9ddbf5..4f3f210 100644
--- a/tool/pldm_cmd_helper.cpp
+++ b/tool/pldm_cmd_helper.cpp
@@ -38,8 +38,7 @@
if (-1 == sockFd)
{
returnCode = -errno;
- std::cerr << "Failed to create the socket : RC = " << sockFd
- << std::endl;
+ std::cerr << "Failed to create the socket : RC = " << sockFd << "\n";
return returnCode;
}
std::cout << "Success in creating the socket : RC = " << sockFd
@@ -59,7 +58,7 @@
{
returnCode = -errno;
std::cerr << "Failed to connect to socket : RC = " << returnCode
- << std::endl;
+ << "\n";
return returnCode;
}
std::cout << "Success in connecting to socket : RC = " << returnCode
@@ -71,7 +70,7 @@
{
returnCode = -errno;
std::cerr << "Failed to send message type as pldm to mctp : RC = "
- << returnCode << std::endl;
+ << returnCode << "\n";
return returnCode;
}
std::cout << "Success in sending message type as pldm to mctp : RC = "
@@ -81,8 +80,7 @@
if (-1 == result)
{
returnCode = -errno;
- std::cerr << "Write to socket failure : RC = " << returnCode
- << std::endl;
+ std::cerr << "Write to socket failure : RC = " << returnCode << "\n";
return returnCode;
}
std::cout << "Write to socket successful : RC = " << result << std::endl;
@@ -92,14 +90,13 @@
if (0 == peekedLength)
{
std::cerr << "Socket is closed : peekedLength = " << peekedLength
- << std::endl;
+ << "\n";
return returnCode;
}
else if (peekedLength <= -1)
{
returnCode = -errno;
- std::cerr << "recv() system call failed : RC = " << returnCode
- << std::endl;
+ std::cerr << "recv() system call failed : RC = " << returnCode << "\n";
return returnCode;
}
else
@@ -118,9 +115,9 @@
else
{
std::cerr << "Failure to read peeked length packet : RC = "
- << returnCode << std::endl;
- std::cerr << "peekedLength: " << peekedLength << std::endl;
- std::cerr << "Total length: " << recvDataLength << std::endl;
+ << returnCode << "\n";
+ std::cerr << "peekedLength: " << peekedLength << "\n";
+ std::cerr << "Total length: " << recvDataLength << "\n";
return returnCode;
}
@@ -146,14 +143,14 @@
else
{
std::cerr << "Failure to read response length packet: length = "
- << recvDataLength << std::endl;
+ << recvDataLength << "\n";
return returnCode;
}
}
else
{
std::cerr << "On first recv(),request != response : RC = "
- << returnCode << std::endl;
+ << returnCode << "\n";
return returnCode;
}
}
@@ -162,7 +159,7 @@
{
returnCode = -errno;
std::cerr << "Failed to shutdown the socket : RC = " << returnCode
- << std::endl;
+ << "\n";
return returnCode;
}
@@ -177,7 +174,7 @@
if (rc != PLDM_SUCCESS)
{
std::cerr << "Failed to encode request message for " << pldmType << ":"
- << commandName << " rc = " << rc << std::endl;
+ << commandName << " rc = " << rc << "\n";
return;
}
@@ -195,7 +192,7 @@
if (rc != PLDM_SUCCESS)
{
- std::cerr << "Failed to receive from socket: RC = " << rc << std::endl;
+ std::cerr << "Failed to receive from socket: RC = " << rc << "\n";
return;
}
@@ -210,4 +207,4 @@
}
} // namespace helper
-} // namespace pldmtool
\ No newline at end of file
+} // namespace pldmtool
diff --git a/utilities/requester/set_state_effecter.cpp b/utilities/requester/set_state_effecter.cpp
index 09f5295..b20cb22 100644
--- a/utilities/requester/set_state_effecter.cpp
+++ b/utilities/requester/set_state_effecter.cpp
@@ -29,7 +29,7 @@
if (rc != PLDM_SUCCESS)
{
std::cerr << "Message encode failure. PLDM error code = " << std::hex
- << std::showbase << rc << std::endl;
+ << std::showbase << rc << "\n";
return -1;
}
@@ -37,7 +37,8 @@
int fd = pldm_open();
if (-1 == fd)
{
- std::cerr << "Failed to init mctp" << std::endl;
+ std::cerr << "Failed to init mctp"
+ << "\n";
return -1;
}
@@ -49,7 +50,7 @@
if (0 > rc)
{
std::cerr << "Failed to send message/receive response. RC = " << rc
- << ", errno = " << errno << std::endl;
+ << ", errno = " << errno << "\n";
return -1;
}
pldm_msg* response = reinterpret_cast<pldm_msg*>(responseMsg);
diff --git a/utilities/requester/set_state_effecter_async.cpp b/utilities/requester/set_state_effecter_async.cpp
index 47d8dd1..8ce7d35 100644
--- a/utilities/requester/set_state_effecter_async.cpp
+++ b/utilities/requester/set_state_effecter_async.cpp
@@ -35,7 +35,7 @@
if (rc != PLDM_SUCCESS)
{
std::cerr << "Message encode failure. PLDM error code = " << std::hex
- << std::showbase << rc << std::endl;
+ << std::showbase << rc << "\n";
return -1;
}
@@ -43,7 +43,8 @@
int fd = pldm_open();
if (-1 == fd)
{
- std::cerr << "Failed to init mctp" << std::endl;
+ std::cerr << "Failed to init mctp"
+ << "\n";
return -1;
}
@@ -79,7 +80,7 @@
if (0 > rc)
{
std::cerr << "Failed to send message/receive response. RC = " << rc
- << ", errno = " << errno << std::endl;
+ << ", errno = " << errno << "\n";
return -1;
}