blob: 27dfef5f98a60e4efad53a70f3d2355ec7587552 [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{
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -05008namespace details
Adriana Kobylakc20dae82017-02-15 13:44:16 -06009{
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050010void commit(const char* name)
11{
12 using phosphor::logging::log;
Adriana Kobylak205b1132017-02-06 20:15:29 -060013 constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
Leonel Gonzalez3064a192017-03-16 13:47:40 -050014 constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
Adriana Kobylak205b1132017-02-06 20:15:29 -060015 constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
16
Adriana Kobylak205b1132017-02-06 20:15:29 -060017 constexpr auto IFACE_INTERNAL("xyz.openbmc_project.Logging.Internal.Manager");
18
19 // Transaction id is located at the end of the string separated by a period.
20
21 auto b = sdbusplus::bus::new_default();
22 auto mapper = b.new_method_call(
23 MAPPER_BUSNAME,
24 MAPPER_PATH,
25 MAPPER_INTERFACE,
26 "GetObject");
27 mapper.append(OBJ_INTERNAL, std::vector<std::string>({IFACE_INTERNAL}));
28
29 auto mapperResponseMsg = b.call(mapper);
30 if (mapperResponseMsg.is_method_error())
31 {
32 log<level::ERR>("Error in mapper call");
33 return;
34 }
35
36 std::map<std::string, std::vector<std::string>> mapperResponse;
37 mapperResponseMsg.read(mapperResponse);
38 if (mapperResponse.empty())
39 {
40 log<level::ERR>("Error reading mapper response");
41 return;
42 }
43
44 const auto& host = mapperResponse.cbegin()->first;
45 auto m = b.new_method_call(
46 host.c_str(),
47 OBJ_INTERNAL,
48 IFACE_INTERNAL,
49 "Commit");
50 uint64_t id = sdbusplus::server::transaction::get_id();
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050051 m.append(id, name);
Adriana Kobylak205b1132017-02-06 20:15:29 -060052 b.call_noreply(m);
Adriana Kobylakc20dae82017-02-15 13:44:16 -060053}
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050054} // namespace details
55
56void commit(std::string&& name)
57{
58 log<level::ERR>("method is deprecated, use commit() with exception type");
59 phosphor::logging::details::commit(name.c_str());
60}
Adriana Kobylakc20dae82017-02-15 13:44:16 -060061
62} // namespace logging
63} // namespace phosphor
64