prevent logspam from getObjectInterfaces
prevent logspam from "Failed to GetObject".
The function does not print anymore and its caller can print an error
if needed.
The error defaults to phosphor::logging::level::DEBUG since it's
looping over the associations.
Therefore, failure in one codepath does not constitute an error.
Tested: logspam is gone.
Change-Id: Ie800181ff80ed56846815ea377f347a784d49521
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/dbus-sdr/sdrutils.cpp b/dbus-sdr/sdrutils.cpp
index 65f651b..e7ed347 100644
--- a/dbus-sdr/sdrutils.cpp
+++ b/dbus-sdr/sdrutils.cpp
@@ -352,7 +352,7 @@
namespace ipmi
{
-std::map<std::string, std::vector<std::string>>
+std::optional<std::map<std::string, std::vector<std::string>>>
getObjectInterfaces(const char* path)
{
std::map<std::string, std::vector<std::string>> interfacesResponse;
@@ -372,9 +372,7 @@
}
catch (const std::exception& e)
{
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Failed to GetObject", phosphor::logging::entry("PATH=%s", path),
- phosphor::logging::entry("WHAT=%s", e.what()));
+ return std::nullopt;
}
return interfacesResponse;
@@ -567,12 +565,21 @@
// Download the interfaces for the sensor from
// Entity-Manager to find the name of the configuration
// interface.
- std::map<std::string, std::vector<std::string>>
- sensorInterfacesResponse =
+ std::optional<std::map<std::string, std::vector<std::string>>>
+ sensorInterfacesResponseOpt =
getObjectInterfaces(sensorConfigPath.c_str());
+ if (!sensorInterfacesResponseOpt.has_value())
+ {
+ phosphor::logging::log<phosphor::logging::level::DEBUG>(
+ "Failed to GetObject",
+ phosphor::logging::entry("PATH=%s", sensorConfigPath.c_str()));
+ continue;
+ }
+
const std::string* configurationInterface =
- getSensorConfigurationInterface(sensorInterfacesResponse);
+ getSensorConfigurationInterface(
+ sensorInterfacesResponseOpt.value());
// If there are multi association path settings and only one path exist,
// we need to continue if cannot find configuration interface for this
diff --git a/include/dbus-sdr/sdrutils.hpp b/include/dbus-sdr/sdrutils.hpp
index 7a001a6..b78e226 100644
--- a/include/dbus-sdr/sdrutils.hpp
+++ b/include/dbus-sdr/sdrutils.hpp
@@ -367,7 +367,7 @@
namespace ipmi
{
-std::map<std::string, std::vector<std::string>>
+std::optional<std::map<std::string, std::vector<std::string>>>
getObjectInterfaces(const char* path);
std::map<std::string, Value> getEntityManagerProperties(const char* path,