PEL: Create class to read from the journal
Create a Journal class that can extract messages out of the journal and
return them as a vector of strings that look like:
"Dec 14 15:58:17 systemd[1]: systemd-tmpfiles-clean.service: Deactivated
successfully."
It can either grab the previous N entries, or the previous N entries
that match a specific SYSLOG_IDENTIFIER value.
The class follows the same strategy as the DataInterface class where a
base class pointer is passed into the PEL Manager class so that during
unit test it can be mocked.
Future commits will capture the journal into PEL UserData sections.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I9f4bb304c4b213165049fa00de2e62f962ae67f1
diff --git a/extensions/openpower-pels/manager.hpp b/extensions/openpower-pels/manager.hpp
index 44a9ec2..8f439a5 100644
--- a/extensions/openpower-pels/manager.hpp
+++ b/extensions/openpower-pels/manager.hpp
@@ -5,6 +5,7 @@
#include "data_interface.hpp"
#include "event_logger.hpp"
#include "host_notifier.hpp"
+#include "journal.hpp"
#include "log_manager.hpp"
#include "paths.hpp"
#include "pel.hpp"
@@ -48,13 +49,14 @@
*/
Manager(phosphor::logging::internal::Manager& logManager,
std::unique_ptr<DataInterfaceBase> dataIface,
- EventLogger::LogFunction creatorFunc) :
+ EventLogger::LogFunction creatorFunc,
+ std::unique_ptr<JournalBase> journal) :
PELInterface(logManager.getBus(), OBJ_LOGGING),
_logManager(logManager), _eventLogger(std::move(creatorFunc)),
_repo(getPELRepoPath()),
_registry(getPELReadOnlyDataPath() / message::registryFileName),
_event(sdeventplus::Event::get_default()),
- _dataIface(std::move(dataIface))
+ _dataIface(std::move(dataIface)), _journal(std::move(journal))
{
for (const auto& entry : _logManager.entries)
{
@@ -82,8 +84,10 @@
Manager(phosphor::logging::internal::Manager& logManager,
std::unique_ptr<DataInterfaceBase> dataIface,
EventLogger::LogFunction creatorFunc,
+ std::unique_ptr<JournalBase> journal,
std::unique_ptr<HostInterface> hostIface) :
- Manager(logManager, std::move(dataIface), std::move(creatorFunc))
+ Manager(logManager, std::move(dataIface), std::move(creatorFunc),
+ std::move(journal))
{
_hostNotifier = std::make_unique<HostNotifier>(
_repo, *(_dataIface.get()), std::move(hostIface));
@@ -506,6 +510,11 @@
std::unique_ptr<DataInterfaceBase> _dataIface;
/**
+ * @brief Object used to read from the journal
+ */
+ std::unique_ptr<JournalBase> _journal;
+
+ /**
* @brief The map used to keep track of PEL entry pointer associated with
* event log.
*/