summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2016-10-10 11:39:20 -0500
committerPatrick Williams <patrick@stwcx.xyz>2016-11-08 17:59:52 +0000
commit1db1bd35557ba01323cbda710b4fc7ceb7dd9a13 (patch)
tree0a7d1353fc2ee82a23d2d90f82c4525c44dce121
parent184690dfce8ea2b8736d9d5de782637bd90e4103 (diff)
downloadphosphor-logging-1db1bd35557ba01323cbda710b4fc7ceb7dd9a13.tar.gz
phosphor-logging-1db1bd35557ba01323cbda710b4fc7ceb7dd9a13.zip
Create log manager server
Error/event log dbus object with a placeholder method. Change-Id: Icfa3f0dcddb3f47a62d8480a936bd8baa4b49760 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
-rw-r--r--log_manager.cpp102
1 files changed, 102 insertions, 0 deletions
diff --git a/log_manager.cpp b/log_manager.cpp
new file mode 100644
index 0000000..1cc1ce2
--- /dev/null
+++ b/log_manager.cpp
@@ -0,0 +1,102 @@
+#include <stdio.h>
+#include <sdbusplus/vtable.hpp>
+#include <systemd/sd-bus.h>
+#include "log.hpp"
+
+/*
+ * @fn commit()
+ * @brief Create an error/event log based on a message id
+ * @param[in] msg - dbus message
+ * @param[in] user_data - user data
+ * @param[in] error - dbus error
+ * @return Commit id
+ */
+auto commit(sd_bus_message *msg, void *user_data, sd_bus_error *error)
+{
+ int rc = 0;
+
+ return rc;
+}
+
+constexpr sdbusplus::vtable::vtable_t log_vtable[] =
+{
+ sdbusplus::vtable::start(),
+
+ sdbusplus::vtable::method("Commit", "i", "i", commit),
+ sdbusplus::vtable::end()
+};
+
+int main(int argc, char *argv[])
+{
+ constexpr const auto dbusLogObj = "/xyz/openbmc_project/Logging";
+ constexpr const auto dbusLogName = "xyz.openbmc_project.Logging";
+ int rc = -1;
+ sd_bus *bus = nullptr;
+
+ rc = sd_bus_open_system(&bus);
+ if (rc < 0)
+ {
+ logging::log<logging::level::ERR>("Failed to open system bus",
+ logging::entry("DESCRIPTION=%s", strerror(-rc)));
+ goto cleanup;
+ }
+
+ rc = sd_bus_add_object_manager(bus, nullptr, dbusLogObj);
+ if (rc < 0)
+ {
+ logging::log<logging::level::ERR>("Failed to add object mgr",
+ logging::entry("DESCRIPTION=%s", strerror(-rc)));
+ goto cleanup;
+ }
+
+ rc = sd_bus_add_object_vtable(bus,
+ nullptr,
+ dbusLogObj,
+ dbusLogName,
+ log_vtable,
+ nullptr);
+ if (rc < 0)
+ {
+ logging::log<logging::level::ERR>("Failed to add vtable",
+ logging::entry("DESCRIPTION=%s", strerror(-rc)));
+ goto cleanup;
+ }
+
+ rc = sd_bus_request_name(bus, dbusLogName, 0);
+ if (rc < 0)
+ {
+ logging::log<logging::level::ERR>("Failed to acquire service name",
+ logging::entry("DESCRIPTION=%s", strerror(-rc)));
+ }
+ else
+ {
+ for(;;)
+ {
+ rc = sd_bus_process(bus, nullptr);
+ if (rc < 0)
+ {
+ logging::log<logging::level::ERR>("Failed to connect to bus",
+ logging::entry("DESCRIPTION=%s", strerror(-rc)));
+ break;
+ }
+ if (rc > 0)
+ {
+ continue;
+ }
+
+ rc = sd_bus_wait(bus, (uint64_t) - 1);
+ if (rc < 0)
+ {
+ logging::log<logging::level::ERR>("Failed to wait on bus",
+ logging::entry("DESCRIPTION=%s", strerror(-rc)));
+ break;
+ }
+ }
+ }
+
+cleanup:
+ sd_bus_unref(bus);
+
+ return rc;
+}
+
OpenPOWER on IntegriCloud