sdr-dbus: Reduce log spam on bitmap error

Remove the log for out_of_range error for
getSensorNumberFromPath and getPathFromSensorNumber. Log only once at
the end of looping through the sensor tree instead of for every sensor.

Tested:
The spam of
```
bimap<>: invalid key
```
is now gone.

Change-Id: Ifc22141cc5450b57ce272c46537240084d94d2aa
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/dbus-sdr/sdrutils.cpp b/dbus-sdr/sdrutils.cpp
index 3e7b966..d148d9a 100644
--- a/dbus-sdr/sdrutils.cpp
+++ b/dbus-sdr/sdrutils.cpp
@@ -271,7 +271,6 @@
     }
     catch (const std::out_of_range& e)
     {
-        phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
         return invalidSensorNumber;
     }
 }
@@ -305,7 +304,6 @@
     }
     catch (const std::out_of_range& e)
     {
-        phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
         return std::string();
     }
 }
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index 55ba6d9..5d23a19 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -37,6 +37,7 @@
 #include <chrono>
 #include <cmath>
 #include <cstring>
+#include <format>
 #include <iostream>
 #include <map>
 #include <memory>
@@ -2512,6 +2513,7 @@
 
     auto& ipmiDecoratorPaths = getIpmiDecoratorPaths(ctx);
 
+    size_t invalidSensorNumberErrCount = 0;
     for (const auto& sensor : sensorTree)
     {
         const std::string& sensorObjPath = sensor.first;
@@ -2571,26 +2573,38 @@
                 if (entityInstanceValue == entityInstance)
                 {
                     auto recordId = getSensorNumberFromPath(sensorObjPath);
-                    if (recordId != invalidSensorNumber)
+                    if (recordId == invalidSensorNumber)
                     {
-                        sensorList.emplace_back(sensorObjPath, sensorTypeValue,
-                                                recordId, entityIdValue,
-                                                entityInstanceValue);
+                        ++invalidSensorNumberErrCount;
+                        continue;
                     }
-                }
-            }
-            else if (entityInstanceValue >= instanceStart)
-            {
-                auto recordId = getSensorNumberFromPath(sensorObjPath);
-                if (recordId != invalidSensorNumber)
-                {
                     sensorList.emplace_back(sensorObjPath, sensorTypeValue,
                                             recordId, entityIdValue,
                                             entityInstanceValue);
                 }
             }
+            else if (entityInstanceValue >= instanceStart)
+            {
+                auto recordId = getSensorNumberFromPath(sensorObjPath);
+                if (recordId == invalidSensorNumber)
+                {
+                    ++invalidSensorNumberErrCount;
+                    continue;
+                }
+                sensorList.emplace_back(sensorObjPath, sensorTypeValue,
+                                        recordId, entityIdValue,
+                                        entityInstanceValue);
+            }
         }
     }
+    if (invalidSensorNumberErrCount != 0)
+    {
+        phosphor::logging::log<phosphor::logging::level::ERR>(
+            std::format(
+                "getSensorNumberFromPath returned invalidSensorNumber {} times",
+                invalidSensorNumberErrCount)
+                .data());
+    }
 
     auto cmpFunc = [](sensorInfo first, sensorInfo second) {
         return first.entityInstance <= second.entityInstance;