PLDM: Implementing Phosphor-Logging/LG2 logging
This commit adds changes in PLDM for implementing
structured LG2 logging, thereby moving away from
std::cout/cerr practice of logging which are
output streams and not logging mechanism.
PLDM now can make use of lg2 features like accurate
CODE LINE Number and CODE_FUNCTION Name and better
detailing in json object values which can be used in
log tracking.
More detailed logging change:
https://gist.github.com/riyadixitagra/c251685c1ba84248181891f7bc282395
Tested:
Ran a power off, on, cycle, and reset-reload.
Change-Id: I0485035f15f278c3fd172f0581b053c1c37f3a5b
Signed-off-by: Riya Dixit <riyadixitagra@gmail.com>
diff --git a/libpldmresponder/bios_enum_attribute.cpp b/libpldmresponder/bios_enum_attribute.cpp
index e878827..7197553 100644
--- a/libpldmresponder/bios_enum_attribute.cpp
+++ b/libpldmresponder/bios_enum_attribute.cpp
@@ -4,8 +4,12 @@
#include "common/utils.hpp"
+#include <phosphor-logging/lg2.hpp>
+
#include <iostream>
+PHOSPHOR_LOG2_USING;
+
using namespace pldm::utils;
namespace pldm
@@ -113,8 +117,8 @@
}
else
{
- std::cerr << "Unknown D-Bus property type, TYPE="
- << dBusMap->propertyType << "\n";
+ error("Unknown D-Bus property type, TYPE={PROP_TYPE}", "PROP_TYPE",
+ dBusMap->propertyType);
throw std::invalid_argument("Unknown D-BUS property type");
}
valMap.emplace(value, possibleValues[pos]);
@@ -238,8 +242,8 @@
auto iter = valMap.find(newPropVal);
if (iter == valMap.end())
{
- std::cerr << "Could not find index for new BIOS enum, value="
- << std::get<std::string>(newPropVal) << "\n";
+ error("Could not find index for new BIOS enum, value={PROP_VAL}",
+ "PROP_VAL", std::get<std::string>(newPropVal));
return PLDM_ERROR;
}
auto currentValue = iter->second;