Create a SEL error log
Log the SEL data to the journal and call the commit
interface to write the error log with the data.
Change-Id: Ifcb842e37f2fdb14f80ab24651d565da05da47bf
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index 95faaf1..45860de 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -32,8 +32,8 @@
transporthandler.cpp \
globalhandler.cpp \
groupext.cpp
-libapphandler_la_LDFLAGS = $(SYSTEMD_LIBS) $(libmapper_LIBS) -version-info 0:0:0 -shared
-libapphandler_la_CXXFLAGS = $(SYSTEMD_CFLAGS) $(libmapper_CFLAGS)
+libapphandler_la_LDFLAGS = $(SYSTEMD_LIBS) $(libmapper_LIBS) $(PHOSPHOR_LOGGING_LIBS) -version-info 0:0:0 -shared
+libapphandler_la_CXXFLAGS = $(SYSTEMD_CFLAGS) $(libmapper_CFLAGS) $(PHOSPHOR_LOGGING_CFLAGS)
libsysintfcmdsdir = ${libdir}/ipmid-providers
libsysintfcmds_LTLIBRARIES = libsysintfcmds.la
@@ -52,4 +52,4 @@
nobase_include_HEADERS = \
host-ipmid/ipmid-api.h
-SUBDIRS = test
\ No newline at end of file
+SUBDIRS = test
diff --git a/configure.ac b/configure.ac
index 5dc3e7f..daba2c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,6 +15,7 @@
# Checks for libraries.
AC_CHECK_LIB([mapper], [mapper_get_service], ,[AC_MSG_ERROR([Could not find libmapper...openbmc/phosphor-objmgr package required])])
PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221])
+PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging],, [AC_MSG_ERROR([Could not find phosphor-logging...openbmc/phosphor-logging package required])])
# Checks for header files.
AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd developement package required])])
diff --git a/storageaddsel.cpp b/storageaddsel.cpp
index 84e3092..0b40d47 100644
--- a/storageaddsel.cpp
+++ b/storageaddsel.cpp
@@ -8,12 +8,15 @@
#include <memory>
#include <systemd/sd-bus.h>
#include <mapper.h>
+#include <elog.hpp>
+#include <elog-errors-HostEvent.hpp>
#include "host-ipmid/ipmid-api.h"
#include "sensorhandler.h"
#include "storagehandler.h"
using namespace std;
+using namespace phosphor::logging;
//////////////////////////
struct esel_section_headers_t {
@@ -185,6 +188,26 @@
const char *object_name = "/org/openbmc/records/events";
char *bus_name = NULL;
+ // Allocate enough space to represent the data in hex separated by spaces,
+ // to mimic how IPMI would display the data.
+ unique_ptr<char[]> selData(new char[debuglen*3]());
+ uint32_t i = 0;
+ for(i = 0; i < debuglen; i++)
+ {
+ sprintf(&selData[i*3], "%02x ", 0xFF & ((char*)debug)[i]);
+ }
+ log<level::INFO>("Received Host Event", entry("ESEL=%s", selData.get()));
+
+ try
+ {
+ elog<org::open_power::Error::Host::Event>(
+ prev_entry<org::open_power::Error::Host::Event::ESEL>());
+ }
+ catch (elogException<org::open_power::Error::Host::Event>& e)
+ {
+ commit(e.name());
+ }
+
mbus = ipmid_get_sd_bus_connection();
r = mapper_get_service(mbus, object_name, &bus_name);
if (r < 0) {