summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2017-08-03 15:54:43 -0500
committerGunnar Mills <gmills@us.ibm.com>2017-08-21 14:26:22 +0000
commit9679d43ea9a0d2ed89c8eb88851eee838a3e767c (patch)
tree024788674bebd6a77dbc5053a90ce0d93f6e4d77 /src
parent2df09e242d6dd5961d831bd179f73489eba526ed (diff)
downloadphosphor-dbus-monitor-9679d43ea9a0d2ed89c8eb88851eee838a3e767c.tar.gz
phosphor-dbus-monitor-9679d43ea9a0d2ed89c8eb88851eee838a3e767c.zip
Create new Elog class
Created new Elog callback, which will create an error log. This is just the base, more to come. Change-Id: I50c12c8bff0942b5cb027e38d0cc8691e8a241b4 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/elog.cpp33
-rw-r--r--src/elog.hpp69
-rw-r--r--src/templates/elog.mako.cpp0
4 files changed, 106 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index d530b46..211cb9f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,13 +7,16 @@ sbin_PROGRAMS = phosphor-dbus-monitor
phosphor_dbus_monitor_SOURCES = \
journal.cpp \
+ elog.cpp \
main.cpp \
propertywatch.cpp
phosphor_dbus_monitor_LDADD = \
$(SDBUSPLUS_LIBS) \
+ $(PHOSPHOR_DBUS_INTERFACES_LIBS) \
$(PHOSPHOR_LOGGING_LIBS)
phosphor_dbus_monitor_CXXFLAGS = \
$(SDBUSPLUS_CFLAGS) \
+ $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) \
$(PHOSPHOR_LOGGING_CFLAGS)
BUILT_SOURCES = generated.hpp
@@ -25,6 +28,7 @@ TEMPLATES = \
templates/count.mako.cpp \
templates/generated.mako.hpp \
templates/journal.mako.cpp \
+ templates/elog.mako.cpp \
templates/method.mako.cpp
generated.hpp: $(PDMGEN) $(YAML_PATH) $(TEMPLATES)
diff --git a/src/elog.cpp b/src/elog.cpp
new file mode 100644
index 0000000..9f937c3
--- /dev/null
+++ b/src/elog.cpp
@@ -0,0 +1,33 @@
+/**
+ * Copyright © 2017 IBM Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "elog.hpp"
+
+namespace phosphor
+{
+namespace dbus
+{
+namespace monitoring
+{
+
+void ElogBase::operator()()
+{
+ log();
+}
+
+
+} // namespace monitoring
+} // namespace dbus
+} // namespace phosphor
diff --git a/src/elog.hpp b/src/elog.hpp
new file mode 100644
index 0000000..f138b0b
--- /dev/null
+++ b/src/elog.hpp
@@ -0,0 +1,69 @@
+#pragma once
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
+#include "callback.hpp"
+#include <sdbusplus/exception.hpp>
+
+namespace phosphor
+{
+namespace dbus
+{
+namespace monitoring
+{
+
+/** @class ElogBase
+ * @brief Elog callback implementation.
+ *
+ * The elog callback logs the elog and
+ * elog metadata.
+ */
+class ElogBase : public Callback
+{
+ public:
+ ElogBase(const ElogBase&) = delete;
+ ElogBase(ElogBase&&) = default;
+ ElogBase& operator=(const ElogBase&) = delete;
+ ElogBase& operator=(ElogBase&&) = default;
+ virtual ~ElogBase() = default;
+ ElogBase() :
+ Callback(){}
+
+ /** @brief Callback interface implementation. */
+ void operator()() override;
+
+ private:
+ /** @brief Delegate type specific calls to subclasses. */
+ virtual void log() const = 0;
+};
+
+
+/** @class Elog
+ * @brief C++ type specific logic for the elog callback.
+ *
+ * @tparam T - Error log type
+ */
+template <typename T>
+class Elog : public ElogBase
+{
+ public:
+ Elog(const Elog&) = delete;
+ Elog(Elog&&) = default;
+ Elog& operator=(const Elog&) = delete;
+ Elog& operator=(Elog&&) = default;
+ ~Elog() = default;
+ Elog() :
+ ElogBase() {}
+
+ private:
+ /** @brief elog interface implementation. */
+ void log() const override
+ {
+
+ using namespace phosphor::logging;
+ report<T>();
+ }
+};
+
+} // namespace monitoring
+} // namespace dbus
+} // namespace phosphor
diff --git a/src/templates/elog.mako.cpp b/src/templates/elog.mako.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/templates/elog.mako.cpp
OpenPOWER on IntegriCloud