regulators: Improve journal interface
Improve the interface to the system journal:
* Create class hierarchy to allow dynamic selection of implementation
* Move to standard gmock interface for mock implementation
* Make design consistent with error logging interface
* Support logging a vector of strings for use with nested exceptions
Create the following class hierarchy:
* Journal: Abstract base class that defines the interface
* SystemdJournal: Implementation that writes to systemd journal
* MockJournal: Mock implementation for testing
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I313c2a6c9e866b5ca0c16c09190a8829d5264631
diff --git a/phosphor-regulators/test/mock_journal.hpp b/phosphor-regulators/test/mock_journal.hpp
index e5729e1..6fe93bc 100644
--- a/phosphor-regulators/test/mock_journal.hpp
+++ b/phosphor-regulators/test/mock_journal.hpp
@@ -20,6 +20,44 @@
#include <string>
#include <vector>
+#include <gmock/gmock.h>
+
+namespace phosphor::power::regulators
+{
+
+/**
+ * @class MockJournal
+ *
+ * Mock implementation of the Journal interface.
+ */
+class MockJournal : public Journal
+{
+ public:
+ // Specify which compiler-generated methods we want
+ MockJournal() = default;
+ MockJournal(const MockJournal&) = delete;
+ MockJournal(MockJournal&&) = delete;
+ MockJournal& operator=(const MockJournal&) = delete;
+ MockJournal& operator=(MockJournal&&) = delete;
+ virtual ~MockJournal() = default;
+
+ MOCK_METHOD(void, logDebug, (const std::string& message), (override));
+ MOCK_METHOD(void, logDebug, (const std::vector<std::string>& messages),
+ (override));
+ MOCK_METHOD(void, logError, (const std::string& message), (override));
+ MOCK_METHOD(void, logError, (const std::vector<std::string>& messages),
+ (override));
+ MOCK_METHOD(void, logInfo, (const std::string& message), (override));
+ MOCK_METHOD(void, logInfo, (const std::vector<std::string>& messages),
+ (override));
+};
+
+} // namespace phosphor::power::regulators
+
+// TODO: Remove the functional interface below once all the code has switched to
+// the new Journal interface. Also delete mock_journal.cpp and remove
+// references to it in meson files.
+
/**
* Extensions to the systemd journal interface.
*