blob: 7cb0fd2b5bf55512318f27ff6d8ac66a52af7b7d [file] [log] [blame]
Deepak Kodihalli827b50f2017-02-24 00:00:08 -06001#include "config.h"
Saqib Khan2bb15192017-02-13 13:19:55 -06002#include <phosphor-logging/elog.hpp>
Adriana Kobylakc20dae82017-02-15 13:44:16 -06003
4namespace phosphor
5{
6namespace logging
7{
8
Adriana Kobylak205b1132017-02-06 20:15:29 -06009void commit(std::string&& e)
Adriana Kobylakc20dae82017-02-15 13:44:16 -060010{
Adriana Kobylak205b1132017-02-06 20:15:29 -060011 constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
12 constexpr auto MAPPER_PATH = "/xyz/openbmc_project/ObjectMapper";
13 constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
14
Adriana Kobylak205b1132017-02-06 20:15:29 -060015 constexpr auto IFACE_INTERNAL("xyz.openbmc_project.Logging.Internal.Manager");
16
17 // Transaction id is located at the end of the string separated by a period.
18
19 auto b = sdbusplus::bus::new_default();
20 auto mapper = b.new_method_call(
21 MAPPER_BUSNAME,
22 MAPPER_PATH,
23 MAPPER_INTERFACE,
24 "GetObject");
25 mapper.append(OBJ_INTERNAL, std::vector<std::string>({IFACE_INTERNAL}));
26
27 auto mapperResponseMsg = b.call(mapper);
28 if (mapperResponseMsg.is_method_error())
29 {
30 log<level::ERR>("Error in mapper call");
31 return;
32 }
33
34 std::map<std::string, std::vector<std::string>> mapperResponse;
35 mapperResponseMsg.read(mapperResponse);
36 if (mapperResponse.empty())
37 {
38 log<level::ERR>("Error reading mapper response");
39 return;
40 }
41
42 const auto& host = mapperResponse.cbegin()->first;
43 auto m = b.new_method_call(
44 host.c_str(),
45 OBJ_INTERNAL,
46 IFACE_INTERNAL,
47 "Commit");
48 uint64_t id = sdbusplus::server::transaction::get_id();
49 m.append(id, std::forward<std::string>(e));
50 b.call_noreply(m);
Adriana Kobylakc20dae82017-02-15 13:44:16 -060051}
52
53} // namespace logging
54} // namespace phosphor
55