Add fmtlib for phosphor-debug-collector

Call fmtlib to get additional information from journal.

Tested: built phosphor-debug-collector successfully
        and Unit Test passes.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ibe65637a0b29b76269fb4bc3f498438901c9306a
diff --git a/bmc_dump_entry.cpp b/bmc_dump_entry.cpp
index 20610c7..811ba2d 100644
--- a/bmc_dump_entry.cpp
+++ b/bmc_dump_entry.cpp
@@ -3,6 +3,8 @@
 #include "dump_manager.hpp"
 #include "dump_offload.hpp"
 
+#include <fmt/core.h>
+
 #include <phosphor-logging/log.hpp>
 
 namespace phosphor
@@ -23,7 +25,9 @@
     catch (std::filesystem::filesystem_error& e)
     {
         // Log Error message and continue
-        log<level::ERR>(e.what());
+        log<level::ERR>(
+            fmt::format("Failed to delete dump file, errormsg({})", e.what())
+                .c_str());
     }
 
     // Remove Dump entry D-bus object
diff --git a/core_manager.cpp b/core_manager.cpp
index aa069a7..753a26b 100644
--- a/core_manager.cpp
+++ b/core_manager.cpp
@@ -2,6 +2,8 @@
 
 #include "core_manager.hpp"
 
+#include <fmt/core.h>
+
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/exception.hpp>
 
@@ -76,9 +78,10 @@
     }
     catch (const sdbusplus::exception::SdBusError& e)
     {
-        log<level::ERR>(
-            "Failed to parse dump create message", entry("ERROR=%s", e.what()),
-            entry("REPLY_SIG=%s", mapperResponseMsg.get_signature()));
+        log<level::ERR>(fmt::format("Failed to parse dump create message, "
+                                    "errormsg({}), REPLY_SIG({})",
+                                    e.what(), mapperResponseMsg.get_signature())
+                            .c_str());
         return;
     }
     if (mapperResponse.empty())
diff --git a/core_manager_main.cpp b/core_manager_main.cpp
index aca772b..3e0e459 100644
--- a/core_manager_main.cpp
+++ b/core_manager_main.cpp
@@ -4,6 +4,8 @@
 #include "watch.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
+#include <fmt/core.h>
+
 #include <phosphor-logging/elog-errors.hpp>
 #include <sdbusplus/bus.hpp>
 
@@ -18,8 +20,10 @@
     auto rc = sd_event_default(&event);
     if (rc < 0)
     {
-        log<level::ERR>("Error occurred during the sd_event_default",
-                        entry("RC=%d", rc));
+        log<level::ERR>(
+            fmt::format("Error occurred during the sd_event_default, rc({})",
+                        rc)
+                .c_str());
         report<InternalFailure>();
         return -1;
     }
@@ -33,8 +37,10 @@
         auto rc = sd_event_loop(eventP.get());
         if (rc < 0)
         {
-            log<level::ERR>("Error occurred during the sd_event_loop",
-                            entry("RC=%d", rc));
+            log<level::ERR>(
+                fmt::format("Error occurred during the sd_event_loop, rc({})",
+                            rc)
+                    .c_str());
             elog<InternalFailure>();
         }
     }
diff --git a/dump-extensions/openpower-dumps/dump_manager_resource.cpp b/dump-extensions/openpower-dumps/dump_manager_resource.cpp
index 50c7f59..d3abdbe 100644
--- a/dump-extensions/openpower-dumps/dump_manager_resource.cpp
+++ b/dump-extensions/openpower-dumps/dump_manager_resource.cpp
@@ -6,6 +6,8 @@
 #include "resource_dump_entry.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
+#include <fmt/core.h>
+
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/elog.hpp>
 
@@ -58,11 +60,12 @@
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>(e.what());
-        log<level::ERR>("Error in creating resource dump entry",
-                        entry("OBJECTPATH=%s", objPath.c_str()),
-                        entry("ID=%d", id), entry("TIMESTAMP=%ull", timeStamp),
-                        entry("SIZE=%d", size), entry("SOURCEID=%d", dumpId));
+        log<level::ERR>(fmt::format("Error in creating resource dump entry, "
+                                    "errormsg({}),OBJECTPATH({}),ID({}),"
+                                    "TIMESTAMP({}),SIZE({}),SOURCEID({})",
+                                    e.what(), objPath, id, timeStamp, size,
+                                    dumpId)
+                            .c_str());
         report<InternalFailure>();
         return;
     }
@@ -109,11 +112,12 @@
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>(e.what());
-        log<level::ERR>("Error in creating resource dump entry",
-                        entry("OBJECTPATH=%s", objPath.c_str()),
-                        entry("VSPSTRING=%s", vspString.c_str()),
-                        entry("ID=%d", id));
+        log<level::ERR>(
+            fmt::format(
+                "Error in creating resource dump "
+                "entry,errormsg({}),OBJECTPATH({}), VSPSTRING({}), ID({})",
+                e.what(), objPath, vspString, id)
+                .c_str());
         elog<InternalFailure>();
         return std::string();
     }
diff --git a/dump-extensions/openpower-dumps/dump_manager_system.cpp b/dump-extensions/openpower-dumps/dump_manager_system.cpp
index 4652261..0288788 100644
--- a/dump-extensions/openpower-dumps/dump_manager_system.cpp
+++ b/dump-extensions/openpower-dumps/dump_manager_system.cpp
@@ -6,6 +6,8 @@
 #include "system_dump_entry.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
+#include <fmt/core.h>
+
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/elog.hpp>
 
@@ -56,11 +58,12 @@
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>(e.what());
-        log<level::ERR>("Error in creating system dump entry",
-                        entry("OBJECTPATH=%s", objPath.c_str()),
-                        entry("ID=%d", id), entry("TIMESTAMP=%ull", timeStamp),
-                        entry("SIZE=%d", size), entry("SOURCEID=%d", dumpId));
+        log<level::ERR>(
+            fmt::format(
+                "Error in creating system dump entry, errormsg({}), "
+                "OBJECTPATH({}), ID({}), TIMESTAMP({}),SIZE({}), SOURCEID({})",
+                e.what(), objPath, id, timeStamp, size, dumpId)
+                .c_str());
         report<InternalFailure>();
         return;
     }
@@ -114,10 +117,11 @@
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>(e.what());
-        log<level::ERR>("Error in creating system dump entry",
-                        entry("OBJECTPATH=%s", objPath.c_str()),
-                        entry("ID=%d", id));
+        log<level::ERR>(
+            fmt::format("Error in creating system dump entry, errormsg({}), "
+                        "OBJECTPATH({}), ID({})",
+                        e.what(), objPath, id)
+                .c_str());
         elog<InternalFailure>();
         return std::string();
     }
diff --git a/dump_manager_bmc.cpp b/dump_manager_bmc.cpp
index f570181..2cf23aa 100644
--- a/dump_manager_bmc.cpp
+++ b/dump_manager_bmc.cpp
@@ -7,6 +7,7 @@
 #include "xyz/openbmc_project/Common/error.hpp"
 #include "xyz/openbmc_project/Dump/Create/error.hpp"
 
+#include <fmt/core.h>
 #include <sys/inotify.h>
 #include <unistd.h>
 
@@ -60,10 +61,10 @@
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>(e.what());
-        log<level::ERR>("Error in creating dump entry",
-                        entry("OBJECTPATH=%s", objPath.c_str()),
-                        entry("ID=%d", id));
+        log<level::ERR>(fmt::format("Error in creating dump entry, "
+                                    "errormsg({}), OBJECTPATH({}), ID({})",
+                                    e.what(), objPath.c_str(), id)
+                            .c_str());
         elog<InternalFailure>();
     }
 
@@ -94,8 +95,11 @@
 
         // dreport script execution is failed.
         auto error = errno;
-        log<level::ERR>("Error occurred during dreport function execution",
-                        entry("ERRNO=%d", error));
+        log<level::ERR>(
+            fmt::format(
+                "Error occurred during dreport function execution, errno({})",
+                error)
+                .c_str());
         elog<InternalFailure>();
     }
     else if (pid > 0)
@@ -105,15 +109,20 @@
         if (0 > rc)
         {
             // Failed to add to event loop
-            log<level::ERR>("Error occurred during the sd_event_add_child call",
-                            entry("RC=%d", rc));
+            log<level::ERR>(
+                fmt::format(
+                    "Error occurred during the sd_event_add_child call, rc({})",
+                    rc)
+                    .c_str());
             elog<InternalFailure>();
         }
     }
     else
     {
         auto error = errno;
-        log<level::ERR>("Error occurred during fork", entry("ERRNO=%d", error));
+        log<level::ERR>(
+            fmt::format("Error occurred during fork, errno({})", error)
+                .c_str());
         elog<InternalFailure>();
     }
 
@@ -132,8 +141,9 @@
 
     if (!((std::regex_search(name, match, file_regex)) && (match.size() > 0)))
     {
-        log<level::ERR>("Invalid Dump file name",
-                        entry("FILENAME=%s", file.filename().c_str()));
+        log<level::ERR>(fmt::format("Invalid Dump file name, FILENAME({})",
+                                    file.filename().c_str())
+                            .c_str());
         return;
     }
 
@@ -164,13 +174,13 @@
     }
     catch (const std::invalid_argument& e)
     {
-        log<level::ERR>(e.what());
-        log<level::ERR>("Error in creating dump entry",
-                        entry("OBJECTPATH=%s", objPath.c_str()),
-                        entry("ID=%d", id),
-                        entry("TIMESTAMP=%ull", stoull(msString)),
-                        entry("SIZE=%d", std::filesystem::file_size(file)),
-                        entry("FILENAME=%s", file.c_str()));
+        log<level::ERR>(
+            fmt::format(
+                "Error in creating dump entry, errormsg({}), OBJECTPATH({}), "
+                "ID({}), TIMESTAMP({}), SIZE({}), FILENAME({})",
+                e.what(), objPath.c_str(), id, stoull(msString),
+                std::filesystem::file_size(file), file.filename().c_str())
+                .c_str());
         return;
     }
 }
diff --git a/dump_manager_main.cpp b/dump_manager_main.cpp
index 207de53..1eb5b31 100644
--- a/dump_manager_main.cpp
+++ b/dump_manager_main.cpp
@@ -8,6 +8,8 @@
 #include "watch.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
+#include <fmt/core.h>
+
 #include <phosphor-logging/elog-errors.hpp>
 #include <sdbusplus/bus.hpp>
 
@@ -25,8 +27,10 @@
     auto rc = sd_event_default(&event);
     if (rc < 0)
     {
-        log<level::ERR>("Error occurred during the sd_event_default",
-                        entry("RC=%d", rc));
+        log<level::ERR>(
+            fmt::format("Error occurred during the sd_event_default, rc({})",
+                        rc)
+                .c_str());
         report<InternalFailure>();
         return rc;
     }
@@ -37,22 +41,25 @@
     sigset_t mask;
     if (sigemptyset(&mask) < 0)
     {
-        log<level::ERR>("Unable to initialize signal set",
-                        entry("ERRNO=%d", errno));
+        log<level::ERR>(
+            fmt::format("Unable to initialize signal set, errno({})", errno)
+                .c_str());
         return EXIT_FAILURE;
     }
 
     if (sigaddset(&mask, SIGCHLD) < 0)
     {
-        log<level::ERR>("Unable to add signal to signal set",
-                        entry("ERRNO=%d", errno));
+        log<level::ERR>(
+            fmt::format("Unable to add signal to signal set, errno({})", errno)
+                .c_str());
         return EXIT_FAILURE;
     }
 
     // Block SIGCHLD first, so that the event loop can handle it
     if (sigprocmask(SIG_BLOCK, &mask, nullptr) < 0)
     {
-        log<level::ERR>("Unable to block signal", entry("ERRNO=%d", errno));
+        log<level::ERR>(
+            fmt::format("Unable to block signal, errno({})", errno).c_str());
         return EXIT_FAILURE;
     }
 
@@ -86,8 +93,10 @@
         auto rc = sd_event_loop(eventP.get());
         if (rc < 0)
         {
-            log<level::ERR>("Error occurred during the sd_event_loop",
-                            entry("RC=%d", rc));
+            log<level::ERR>(
+                fmt::format("Error occurred during the sd_event_loop, rc({})",
+                            rc)
+                    .c_str());
             elog<InternalFailure>();
         }
     }
diff --git a/dump_offload.cpp b/dump_offload.cpp
index 374a657..3c4b834 100644
--- a/dump_offload.cpp
+++ b/dump_offload.cpp
@@ -2,6 +2,7 @@
 
 #include "dump_offload.hpp"
 
+#include <fmt/core.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/un.h>
@@ -54,8 +55,10 @@
                             NULL, &timeVal);
         if (retVal <= 0)
         {
-            log<level::ERR>("writeOnUnixSocket: select() failed",
-                            entry("ERRNO=%d", errno));
+            log<level::ERR>(
+                fmt::format("writeOnUnixSocket: select() failed, errno({})",
+                            errno)
+                    .c_str());
             std::string msg = "select() failed " + std::string(strerror(errno));
             throw std::runtime_error(msg);
         }
@@ -69,8 +72,10 @@
                     numOfBytesWrote = 0;
                     continue;
                 }
-                log<level::ERR>("writeOnUnixSocket: write() failed",
-                                entry("ERRNO=%d", errno));
+                log<level::ERR>(
+                    fmt::format("writeOnUnixSocket: write() failed, errno({})",
+                                errno)
+                        .c_str());
                 std::string msg =
                     "write() on socket failed " + std::string(strerror(errno));
                 throw std::runtime_error(msg);
@@ -105,23 +110,26 @@
             sizeof(socketAddr.sun_path) - 1);
     if ((unixSocket = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0)) == -1)
     {
-        log<level::ERR>("socketInit: socket() failed",
-                        entry("ERRNO=%d", errno));
+        log<level::ERR>(
+            fmt::format("socketInit: socket() failed, errno({})", errno)
+                .c_str());
         std::string msg = "socket() failed " + std::string(strerror(errno));
         throw std::runtime_error(msg);
     }
     if (bind(unixSocket, (struct sockaddr*)&socketAddr, sizeof(socketAddr)) ==
         -1)
     {
-        log<level::ERR>("socketInit: bind() failed", entry("ERRNO=%d", errno));
+        log<level::ERR>(
+            fmt::format("socketInit: bind() failed, errno({})", errno).c_str());
         close(unixSocket);
         std::string msg = "socket bind failed " + std::string(strerror(errno));
         throw std::runtime_error(msg);
     }
     if (listen(unixSocket, 1) == -1)
     {
-        log<level::ERR>("socketInit: listen() failed",
-                        entry("ERRNO=%d", errno));
+        log<level::ERR>(
+            fmt::format("socketInit: listen() failed, errno({})", errno)
+                .c_str());
         close(unixSocket);
         std::string msg = "listen() failed " + std::string(strerror(errno));
         throw std::runtime_error(msg);
@@ -159,8 +167,10 @@
         int retVal = select(numOfFDs, &readFD, NULL, NULL, &timeVal);
         if (retVal <= 0)
         {
-            log<level::ERR>("select() failed", entry("ERRNO=%d", errno),
-                            entry("DUMP ID=%d", dumpId));
+            log<level::ERR>(
+                fmt::format("select() failed, errno({}), DUMP_ID({})", errno,
+                            dumpId)
+                    .c_str());
             std::string msg = "select() failed " + std::string(strerror(errno));
             throw std::runtime_error(msg);
         }
@@ -169,8 +179,10 @@
             CustomFd socketFD = accept(unixSocket(), NULL, NULL);
             if (socketFD() < 0)
             {
-                log<level::ERR>("accept() failed", entry("ERRNO=%d", errno),
-                                entry("DUMP ID=%d", dumpId));
+                log<level::ERR>(
+                    fmt::format("accept() failed, errno({}), DUMP_ID({})",
+                                errno, dumpId)
+                        .c_str());
                 std::string msg =
                     "accept() failed " + std::string(strerror(errno));
                 throw std::runtime_error(msg);
@@ -180,18 +192,20 @@
             if (!infile.good())
             {
                 // Unable to open the dump file
-                log<level::ERR>("Failed to open the dump from file ",
-                                entry("ERR=%d", errno),
-                                entry("DUMPFILE=%s", dumpPath.c_str()),
-                                entry("DUMP ID=%d", dumpId));
+                log<level::ERR>(
+                    fmt::format("Failed to open the dump from file, errno({}), "
+                                "DUMPFILE({}), DUMP_ID({})",
+                                errno, dumpPath.c_str(), dumpId)
+                        .c_str());
                 elog<Open>(ErrnoOpen(errno), PathOpen(dumpPath.c_str()));
             }
 
             infile.exceptions(std::ifstream::failbit | std::ifstream::badbit |
                               std::ifstream::eofbit);
 
-            log<level::INFO>("Opening File for RW ",
-                             entry("FILENAME=%s", file.filename().c_str()));
+            log<level::INFO>(fmt::format("Opening File for RW, FILENAME({})",
+                                         file.filename().c_str())
+                                 .c_str());
 
             std::filebuf* pbuf = infile.rdbuf();
 
@@ -212,18 +226,21 @@
     {
         std::remove(writePath.c_str());
         auto err = errno;
-        log<level::ERR>("Failed to open", entry("ERR=%s", oe.what()),
-                        entry("OPENINTERFACE=%s", dumpPath.c_str()),
-                        entry("DUMP ID=%d", dumpId));
+        log<level::ERR>(
+            fmt::format(
+                "Failed to open, errormsg({}), OPENINTERFACE({}), DUMP_ID({})",
+                oe.what(), dumpPath.c_str(), dumpId)
+                .c_str());
         elog<Open>(ErrnoOpen(err), PathOpen(dumpPath.c_str()));
     }
     catch (const std::exception& e)
     {
         std::remove(writePath.c_str());
         auto err = errno;
-        log<level::ERR>("Failed to offload dump", entry("ERR=%s", e.what()),
-                        entry("DUMPFILE=%s", writePath.c_str()),
-                        entry("DUMP ID=%d", dumpId));
+        log<level::ERR>(fmt::format("Failed to offload dump, errormsg({}), "
+                                    "DUMPFILE({}), DUMP_ID({})",
+                                    e.what(), writePath.c_str(), dumpId)
+                            .c_str());
         elog<Write>(ErrnoWrite(err), PathWrite(writePath.c_str()));
     }
     std::remove(writePath.c_str());
diff --git a/dump_serialize.cpp b/dump_serialize.cpp
index 823cc4c..427cf57 100644
--- a/dump_serialize.cpp
+++ b/dump_serialize.cpp
@@ -1,5 +1,7 @@
 #include "dump_serialize.hpp"
 
+#include <fmt/core.h>
+
 #include <cereal/archives/binary.hpp>
 #include <cereal/types/set.hpp>
 #include <phosphor-logging/log.hpp>
@@ -37,7 +39,9 @@
     }
     catch (cereal::Exception& e)
     {
-        log<level::ERR>(e.what());
+        log<level::ERR>(
+            fmt::format("Failed to deserialize, errormsg({})", e.what())
+                .c_str());
         std::filesystem::remove(path);
         return false;
     }
diff --git a/dump_utils.cpp b/dump_utils.cpp
index 02c75fb..bcc9800 100644
--- a/dump_utils.cpp
+++ b/dump_utils.cpp
@@ -1,5 +1,7 @@
 #include "dump_utils.hpp"
 
+#include <fmt/core.h>
+
 #include <phosphor-logging/log.hpp>
 
 namespace phosphor
@@ -29,18 +31,19 @@
         reply.read(response);
         if (response.empty())
         {
-            log<level::ERR>("Error in mapper response for getting service name",
-                            entry("PATH=%s", path.c_str()),
-                            entry("INTERFACE=%s", interface.c_str()));
+            log<level::ERR>(fmt::format("Error in mapper response for getting "
+                                        "service name, PATH({}), INTERFACE({})",
+                                        path, interface)
+                                .c_str());
             return std::string{};
         }
     }
     catch (const sdbusplus::exception::SdBusError& e)
     {
-        log<level::ERR>("Error in mapper method call",
-                        entry("ERROR=%s", e.what()),
-                        entry("PATH=%s", path.c_str()),
-                        entry("INTERFACE=%s", interface.c_str()));
+        log<level::ERR>(fmt::format("Error in mapper method call, "
+                                    "errormsg({}), PATH({}), INTERFACE({})",
+                                    e.what(), path, interface)
+                            .c_str());
         return std::string{};
     }
     return response[0].first;
@@ -83,19 +86,20 @@
     }
     catch (const sdbusplus::exception::SdBusError& e)
     {
-        log<level::ERR>("D-Bus call exception",
-                        entry("OBJPATH=%s", hostStateObjPath),
-                        entry("INTERFACE=%s", bootProgressInterface),
-                        entry("EXCEPTION=%s", e.what()));
+        log<level::ERR>(fmt::format("D-Bus call exception, OBJPATH({}), "
+                                    "INTERFACE({}), EXCEPTION({})",
+                                    hostStateObjPath, bootProgressInterface,
+                                    e.what())
+                            .c_str());
         throw std::runtime_error("Failed to get BootProgress stage");
     }
     catch (const std::bad_variant_access& e)
     {
         log<level::ERR>(
-            "Exception raised while read BootProgress property value",
-            entry("OBJPATH=%s", hostStateObjPath),
-            entry("INTERFACE=%s", bootProgressInterface),
-            entry("EXCEPTION=%s", e.what()));
+            fmt::format("Exception raised while read BootProgress property "
+                        "value,  OBJPATH({}), INTERFACE({}), EXCEPTION({})",
+                        hostStateObjPath, bootProgressInterface, e.what())
+                .c_str());
         throw std::runtime_error("Failed to get BootProgress stage");
     }
 
diff --git a/elog_watch.cpp b/elog_watch.cpp
index 764cd33..212171b 100644
--- a/elog_watch.cpp
+++ b/elog_watch.cpp
@@ -7,6 +7,8 @@
 #include "errors_map.hpp"
 #include "xyz/openbmc_project/Dump/Create/error.hpp"
 
+#include <fmt/core.h>
+
 #include <cereal/cereal.hpp>
 #include <phosphor-logging/elog.hpp>
 #include <sdbusplus/exception.hpp>
@@ -69,9 +71,11 @@
     }
     catch (const sdbusplus::exception::SdBusError& e)
     {
-        log<level::ERR>("Failed to parse elog add signal",
-                        entry("ERROR=%s", e.what()),
-                        entry("REPLY_SIG=%s", msg.get_signature()));
+        log<level::ERR>(
+            fmt::format(
+                "Failed to parse elog add signal, errormsg({}), REPLY_SIG({})",
+                e.what(), msg.get_signature())
+                .c_str());
         return;
     }
 
@@ -163,9 +167,11 @@
     }
     catch (const sdbusplus::exception::SdBusError& e)
     {
-        log<level::ERR>("Failed to parse elog del signal",
-                        entry("ERROR=%s", e.what()),
-                        entry("REPLY_SIG=%s", msg.get_signature()));
+        log<level::ERR>(
+            fmt::format(
+                "Failed to parse elog del signal, errormsg({}), REPLY_SIG({})",
+                e.what(), msg.get_signature())
+                .c_str());
         return;
     }
 
diff --git a/host-transport-extensions/pldm/common/pldm_utils.cpp b/host-transport-extensions/pldm/common/pldm_utils.cpp
index 7c15929..b68ad58 100644
--- a/host-transport-extensions/pldm/common/pldm_utils.cpp
+++ b/host-transport-extensions/pldm/common/pldm_utils.cpp
@@ -5,6 +5,8 @@
 #include "dump_utils.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
+#include <fmt/core.h>
+
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 
@@ -25,8 +27,8 @@
     if (fd < 0)
     {
         auto e = errno;
-        log<level::ERR>("pldm_open failed", entry("ERRNO=%d", e),
-                        entry("FD=%d\n", fd));
+        log<level::ERR>(
+            fmt::format("pldm_open failed, errno({}), FD({})", e, fd).c_str());
         elog<NotAllowed>(Reason("Required host dump action via pldm is not "
                                 "allowed due to pldm_open failed"));
     }
diff --git a/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp b/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp
index ef344d1..a16f942 100644
--- a/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp
+++ b/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp
@@ -19,6 +19,7 @@
 #include "pldm_utils.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
+#include <fmt/core.h>
 #include <libpldm/base.h>
 #include <libpldm/file_io.h>
 #include <libpldm/platform.h>
@@ -119,7 +120,8 @@
 
     if (rc != PLDM_SUCCESS)
     {
-        log<level::ERR>("Message encode failure. ", entry("RC=%d", rc));
+        log<level::ERR>(
+            fmt::format("Message encode failure. RC({})", rc).c_str());
         elog<NotAllowed>(Reason("Host dump offload via pldm is not "
                                 "allowed due to encode failed"));
     }
@@ -134,15 +136,15 @@
     if (rc < 0)
     {
         auto e = errno;
-        log<level::ERR>("pldm_send failed", entry("RC=%d", rc),
-                        entry("ERRNO=%d", e));
+        log<level::ERR>(
+            fmt::format("pldm_send failed, RC({}), errno({})", rc, e).c_str());
         elog<NotAllowed>(Reason("Host dump offload via pldm is not "
                                 "allowed due to fileack send failed"));
     }
     pldm_msg* response = reinterpret_cast<pldm_msg*>(responseMsg);
-    log<level::INFO>(
-        "Done. PLDM message",
-        entry("RC=%d", static_cast<uint16_t>(response->payload[0])));
+    log<level::INFO>(fmt::format("Done. PLDM message, RC({})",
+                                 static_cast<uint16_t>(response->payload[0]))
+                         .c_str());
 }
 
 void requestDelete(uint32_t dumpId, uint32_t dumpType)
@@ -176,10 +178,12 @@
 
     if (retCode != PLDM_SUCCESS)
     {
-        log<level::ERR>("Failed to encode pldm FileAck to delete host dump",
-                        entry("SRC_DUMP_ID=%d", dumpId),
-                        entry("PLDM_FILE_IO_TYPE=%d", pldmDumpType),
-                        entry("PLDM_RETURN_CODE=%d", retCode));
+        log<level::ERR>(
+            fmt::format("Failed to encode pldm FileAck to delete host "
+                        "dump,SRC_DUMP_ID({}), "
+                        "PLDM_FILE_IO_TYPE({}),PLDM_RETURN_CODE({})",
+                        dumpId, pldmDumpType, retCode)
+                .c_str());
         elog<NotAllowed>(Reason("Host dump deletion via pldm is not "
                                 "allowed due to encode fileack failed"));
     }
@@ -198,12 +202,13 @@
     if (retCode != PLDM_REQUESTER_SUCCESS)
     {
         auto errorNumber = errno;
-        log<level::ERR>("Failed to send pldm FileAck to delete host dump",
-                        entry("SRC_DUMP_ID=%d", dumpId),
-                        entry("PLDM_FILE_IO_TYPE=%d", pldmDumpType),
-                        entry("PLDM_RETURN_CODE=%d", retCode),
-                        entry("ERRNO=%d", errorNumber),
-                        entry("ERRMSG=%s", strerror(errorNumber)));
+        log<level::ERR>(
+            fmt::format("Failed to send pldm FileAck to delete host dump, "
+                        "SRC_DUMP_ID({}), PLDM_FILE_IO_TYPE({}), "
+                        "PLDM_RETURN_CODE({}), ERRNO({}), ERRMSG({})",
+                        dumpId, pldmDumpType, retCode, errorNumber,
+                        strerror(errorNumber))
+                .c_str());
         elog<NotAllowed>(Reason("Host dump deletion via pldm is not "
                                 "allowed due to fileack send failed"));
     }
@@ -216,16 +221,18 @@
 
     if (retCode || completionCode)
     {
-        log<level::ERR>("Failed to delete host dump",
-                        entry("SRC_DUMP_ID=%d", dumpId),
-                        entry("PLDM_FILE_IO_TYPE=%d", pldmDumpType),
-                        entry("PLDM_RETURN_CODE=%d", retCode),
-                        entry("PLDM_COMPLETION_CODE=%d", completionCode));
+        log<level::ERR>(
+            fmt::format("Failed to delete host dump, SRC_DUMP_ID({}), "
+                        "PLDM_FILE_IO_TYPE({}), PLDM_RETURN_CODE({}), "
+                        "PLDM_COMPLETION_CODE({})",
+                        dumpId, pldmDumpType, retCode, completionCode)
+                .c_str());
         elog<NotAllowed>(Reason("Host dump deletion via pldm is "
                                 "failed"));
     }
 
-    log<level::INFO>("Deleted host dump", entry("SRC_DUMP_ID=%d", dumpId));
+    log<level::INFO>(
+        fmt::format("Deleted host dump, SRC_DUMP_ID({})", dumpId).c_str());
 }
 } // namespace pldm
 } // namespace dump
diff --git a/meson.build b/meson.build
index 7c8ff03..3ef697a 100644
--- a/meson.build
+++ b/meson.build
@@ -44,6 +44,19 @@
     ],
 )
 
+fmt_dep = dependency('fmt', required: false)
+if not fmt_dep.found()
+  fmt_proj = import('cmake').subproject(
+    'fmt',
+    cmake_options: [
+      '-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
+      '-DMASTER_PROJECT=OFF'
+    ],
+    required: false)
+  assert(fmt_proj.found(), 'fmtlib is required')
+  fmt_dep = fmt_proj.dependency('fmt')
+endif
+
 # Disable FORTIFY_SOURCE when compiling with no optimization
 if(get_option('optimization') == '0')
   add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c'])
@@ -158,7 +171,8 @@
         phosphor_dbus_interfaces_dep,
         sdbusplus_dep,
         phosphor_logging_dep,
-        cppfs
+        cppfs,
+        fmt_dep
     ]
 
 phosphor_dump_manager_install = true
@@ -182,7 +196,8 @@
 phosphor_dump_monitor_dependency = [
         phosphor_dbus_interfaces_dep,
         phosphor_logging_dep,
-        cppfs
+        cppfs,
+        fmt_dep
     ]
 
 phosphor_dump_monitor_install = true
@@ -196,9 +211,10 @@
     ]
 
 phosphor_ramoops_monitor_dependency = [
-        phosphor_dbus_interfaces,
-        phosphor_logging,
-        cppfs
+        phosphor_dbus_interfaces_dep,
+        phosphor_logging_dep,
+        cppfs,
+        fmt_dep
     ]
 
 phosphor_ramoops_monitor_install = true
diff --git a/ramoops_manager.cpp b/ramoops_manager.cpp
index a9f15c3..5fed14b 100644
--- a/ramoops_manager.cpp
+++ b/ramoops_manager.cpp
@@ -2,6 +2,8 @@
 
 #include "ramoops_manager.hpp"
 
+#include <fmt/core.h>
+
 #include <sdbusplus/exception.hpp>
 
 namespace phosphor
@@ -53,8 +55,10 @@
     catch (const sdbusplus::exception::SdBusError& e)
     {
         log<level::ERR>(
-            "Failed to parse dump create message", entry("ERROR=%s", e.what()),
-            entry("REPLY_SIG=%s", mapperResponseMsg.get_signature()));
+            fmt::format(
+                "Failed to parse dump create message, error({}), REPLY_SIG({})",
+                e.what(), mapperResponseMsg.get_signature())
+                .c_str());
         return;
     }
     if (mapperResponse.empty())
diff --git a/ramoops_manager_main.cpp b/ramoops_manager_main.cpp
index 6a06386..e352a2d 100644
--- a/ramoops_manager_main.cpp
+++ b/ramoops_manager_main.cpp
@@ -2,6 +2,8 @@
 
 #include "ramoops_manager.hpp"
 
+#include <fmt/core.h>
+
 #include <phosphor-logging/elog-errors.hpp>
 
 int main()
@@ -9,8 +11,10 @@
     fs::path filePath(SYSTEMD_PSTORE_PATH);
     if (!fs::exists(filePath))
     {
-        log<level::ERR>("Pstore file path is not exists",
-                        entry("FILE_PATH = %s", SYSTEMD_PSTORE_PATH));
+        log<level::ERR>(
+            fmt::format("Pstore file path is not exists, FILE_PATH({})",
+                        SYSTEMD_PSTORE_PATH)
+                .c_str());
         return EXIT_FAILURE;
     }
 
diff --git a/subprojects/fmt.wrap b/subprojects/fmt.wrap
new file mode 100644
index 0000000..6847ae5
--- /dev/null
+++ b/subprojects/fmt.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/fmtlib/fmt
+revision = HEAD
diff --git a/test/meson.build b/test/meson.build
index 2f23272..8db5caa 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -36,6 +36,7 @@
                                     gmock_dep,
                                     dump,
                                     phosphor_logging_dep,
+                                    fmt_dep,
                                     cppfs]),
        workdir: meson.current_source_dir())
 endforeach
diff --git a/watch.cpp b/watch.cpp
index 137ff76..8ccfbeb 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -2,6 +2,8 @@
 
 #include "xyz/openbmc_project/Common/error.hpp"
 
+#include <fmt/core.h>
+
 #include <phosphor-logging/elog-errors.hpp>
 
 namespace phosphor
@@ -33,8 +35,9 @@
     // Check if watch DIR exists.
     if (!std::filesystem::is_directory(path))
     {
-        log<level::ERR>("Watch directory doesn't exist",
-                        entry("DIR=%s", path.c_str()));
+        log<level::ERR>(
+            fmt::format("Watch directory doesn't exist, DIR({})", path.c_str())
+                .c_str());
         elog<InternalFailure>();
     }
 
@@ -42,8 +45,11 @@
     if (-1 == wd)
     {
         auto error = errno;
-        log<level::ERR>("Error occurred during the inotify_add_watch call",
-                        entry("ERRNO=%d", error));
+        log<level::ERR>(
+            fmt::format(
+                "Error occurred during the inotify_add_watch call, errno({})",
+                error)
+                .c_str());
         elog<InternalFailure>();
     }
 
@@ -52,8 +58,10 @@
     if (0 > rc)
     {
         // Failed to add to event loop
-        log<level::ERR>("Error occurred during the sd_event_add_io call",
-                        entry("RC=%d", rc));
+        log<level::ERR>(
+            fmt::format(
+                "Error occurred during the sd_event_add_io call, rc({})", rc)
+                .c_str());
         elog<InternalFailure>();
     }
 }
@@ -65,8 +73,10 @@
     if (-1 == fd)
     {
         auto error = errno;
-        log<level::ERR>("Error occurred during the inotify_init1",
-                        entry("ERRNO=%d", error));
+        log<level::ERR>(
+            fmt::format("Error occurred during the inotify_init1, errno({})",
+                        error)
+                .c_str());
         elog<InternalFailure>();
     }
 
@@ -92,8 +102,9 @@
         // Failed to read inotify event
         // Report error and return
         auto error = errno;
-        log<level::ERR>("Error occurred during the read",
-                        entry("ERRNO=%d", error));
+        log<level::ERR>(
+            fmt::format("Error occurred during the read, errno({})", error)
+                .c_str());
         report<InternalFailure>();
         return 0;
     }