Implementing Phosphor-Logging/LG2 logging
This commit introduces changes in the openpower-debug-collector
repository to implement structured logging using the LG2
framework. The existing log calls in the repository,
have been replaced with LG2 logging, facilitates better
log tracking and troubleshooting by offering improved
detail in JSON object values.
Change-Id: Iabea1d0044d27a286f73e34588205b45952ae146
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/watchdog_timeout.cpp b/watchdog_timeout.cpp
index 91fa616..f616312 100644
--- a/watchdog_timeout.cpp
+++ b/watchdog_timeout.cpp
@@ -11,12 +11,11 @@
#include <libphal.H>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <watchdog/watchdog_common.hpp>
#include <watchdog/watchdog_dbus.hpp>
#include <watchdog/watchdog_main.hpp>
-#include <format>
#else
#include <org/open_power/Host/Boot/error.hpp>
#include <phosphor-logging/elog-errors.hpp>
@@ -37,10 +36,9 @@
CLI11_PARSE(app, argc, argv);
#ifdef WATCHDOG_DUMP_COLLECTION
- using namespace phosphor::logging;
using namespace watchdog::dump;
- log<level::INFO>("Host did not respond within watchdog timeout interval");
+ lg2::info("Host did not respond within watchdog timeout interval");
try
{
using namespace openpower::phal;
@@ -58,26 +56,26 @@
// Collect hostboot dump only if the host is in 'Running' state
if (!isHostStateRunning())
{
- log<level::INFO>(
+ lg2::info(
"CurrentHostState is not in 'Running' state. Dump maybe "
"already occurring, skipping this dump request...");
return EXIT_SUCCESS;
}
// SBE boot done, Need to collect hostboot dump
- log<level::INFO>("Handle Hostboot boot failure");
+ lg2::info("Handle Hostboot boot failure");
triggerHostbootDump(timeout);
}
else
{
// SBE boot window, handle SBE boot failure
- log<level::INFO>("Handle SBE boot failure");
+ lg2::info("Handle SBE boot failure");
handleSbeBootError(procTarget, timeout);
}
}
catch (const std::exception& e)
{
- log<level::ERR>(std::format("Exception {} occurred", e.what()).c_str());
+ lg2::error("Exception {ERROR} occurred", "ERROR", e);
std::string eventType =
"org.open_power.Host.Boot.Error.WatchdogTimedOut";
auto ffdc = std::vector<FFDCTuple>{};
@@ -85,7 +83,7 @@
if (!createPel(eventType, additionalData, ffdc))
{
- log<level::ERR>("Failed to create PEL");
+ lg2::error("Failed to create PEL");
}
return EXIT_SUCCESS;