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