PEL: Repository: Added getLogID() as public method

Currently, don't have any public method to get LogID from
the Repository class so added an api "getLogID()" which can be
used to get the LogID by using either OpenBMC event log id or
PEL id (aka Entry ID (EID)).

Tested:
- Tested by below unit test cases.
 - GetLogIDFoundTC
  - With valid PEL ID
  - With valid OpenBMC Event Log ID
 - GetLogIDNotFoundTC
  - With invalid PEL ID
  - With invalid OpenBMC Event Log ID

Signed-off-by: Ramesh Iyyar <rameshi1@in.ibm.com>
Change-Id: Ia621c46f67198fccd88ec5b00c32d4f65be05743
diff --git a/extensions/openpower-pels/repository.hpp b/extensions/openpower-pels/repository.hpp
index 31c569c..0b5cab1 100644
--- a/extensions/openpower-pels/repository.hpp
+++ b/extensions/openpower-pels/repository.hpp
@@ -425,6 +425,26 @@
         return _lastPelID;
     }
 
+    /**
+     * @brief Get the LogID based on the given ObmcLogId or PelId.
+     *
+     * @param[in] id - The ID to find the LogID.
+     *
+     * @return The LogID or an empty optional if not found.
+     *
+     * @note The returned LogID is the fully filled in LogID, i.e.
+     * it has both the PEL and OpenBMC Log IDs, unlike the passed in LogID
+     * which can just have one or the other.
+     */
+    std::optional<LogID> getLogID(const LogID& id) const
+    {
+        if (auto logID = findPEL(id); logID != _pelAttributes.end())
+        {
+            return logID->first;
+        }
+        return std::nullopt;
+    }
+
   private:
     using PELUpdateFunc = std::function<void(PEL&)>;