diff options
author | Adriana Kobylak <anoo@us.ibm.com> | 2017-02-06 20:15:29 -0600 |
---|---|---|
committer | Adriana Kobylak <anoo@linux.vnet.ibm.com> | 2017-02-16 15:55:13 -0600 |
commit | 205b11368d69fce12ed2bf347bf8ae7b5b7dfd3f (patch) | |
tree | dfc6b826ce8a7656eee7a8391150e2ebaf6c98af /elog.cpp | |
parent | c20dae8656898888505df589c32e9f672e03c648 (diff) | |
download | phosphor-logging-205b11368d69fce12ed2bf347bf8ae7b5b7dfd3f.tar.gz phosphor-logging-205b11368d69fce12ed2bf347bf8ae7b5b7dfd3f.zip |
Implement Commit client interface
Implement the Commit client interface to take the
exception unique name and call the dbus Commit interface
to create the error log.
Change-Id: Id780e98efd32b9806ea24e4e551f786a055cc05c
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
Diffstat (limited to 'elog.cpp')
-rw-r--r-- | elog.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
@@ -5,8 +5,49 @@ namespace phosphor namespace logging { -void commit() +void commit(std::string&& e) { + constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; + constexpr auto MAPPER_PATH = "/xyz/openbmc_project/ObjectMapper"; + constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper"; + + constexpr auto OBJ_INTERNAL("/xyz/openbmc_project/Logging/Internal/Manager"); + constexpr auto IFACE_INTERNAL("xyz.openbmc_project.Logging.Internal.Manager"); + + // Transaction id is located at the end of the string separated by a period. + + auto b = sdbusplus::bus::new_default(); + auto mapper = b.new_method_call( + MAPPER_BUSNAME, + MAPPER_PATH, + MAPPER_INTERFACE, + "GetObject"); + mapper.append(OBJ_INTERNAL, std::vector<std::string>({IFACE_INTERNAL})); + + auto mapperResponseMsg = b.call(mapper); + if (mapperResponseMsg.is_method_error()) + { + log<level::ERR>("Error in mapper call"); + return; + } + + std::map<std::string, std::vector<std::string>> mapperResponse; + mapperResponseMsg.read(mapperResponse); + if (mapperResponse.empty()) + { + log<level::ERR>("Error reading mapper response"); + return; + } + + const auto& host = mapperResponse.cbegin()->first; + auto m = b.new_method_call( + host.c_str(), + OBJ_INTERNAL, + IFACE_INTERNAL, + "Commit"); + uint64_t id = sdbusplus::server::transaction::get_id(); + m.append(id, std::forward<std::string>(e)); + b.call_noreply(m); } } // namespace logging |