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/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;
     }