blob: 890fd5d3f3ca0947c75ea51c600f2d2ab7b7f2e8 [file] [log] [blame]
Deepak Kodihalli827b50f2017-02-24 00:00:08 -06001#include "config.h"
Patrick Venturef18bf832018-10-26 18:14:00 -07002
Saqib Khan2bb15192017-02-13 13:19:55 -06003#include <phosphor-logging/elog.hpp>
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -05004#include <stdexcept>
Adriana Kobylakc20dae82017-02-15 13:44:16 -06005
6namespace phosphor
7{
8namespace logging
9{
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050010namespace details
Adriana Kobylakc20dae82017-02-15 13:44:16 -060011{
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050012using namespace sdbusplus::xyz::openbmc_project::Logging::server;
13
14auto _prepareMsg(const char* funcName)
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050015{
16 using phosphor::logging::log;
Patrick Venturef18bf832018-10-26 18:14:00 -070017 constexpr auto IFACE_INTERNAL(
18 "xyz.openbmc_project.Logging.Internal.Manager");
Adriana Kobylak205b1132017-02-06 20:15:29 -060019
20 // Transaction id is located at the end of the string separated by a period.
21
22 auto b = sdbusplus::bus::new_default();
Adriana Kobylak205b1132017-02-06 20:15:29 -060023
Matt Spinler6b300d22020-07-15 13:20:44 -050024 auto m = b.new_method_call(BUSNAME_LOGGING, OBJ_INTERNAL, IFACE_INTERNAL,
25 funcName);
Patrick Venturef18bf832018-10-26 18:14:00 -070026 return m;
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050027}
28
Lei YUb50c7052021-01-21 16:02:26 +080029uint32_t commit(const char* name)
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050030{
31 auto msg = _prepareMsg("Commit");
Adriana Kobylak205b1132017-02-06 20:15:29 -060032 uint64_t id = sdbusplus::server::transaction::get_id();
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050033 msg.append(id, name);
34 auto bus = sdbusplus::bus::new_default();
Lei YUb50c7052021-01-21 16:02:26 +080035 auto reply = bus.call(msg);
36 uint32_t entryID;
37 reply.read(entryID);
38 return entryID;
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050039}
40
Lei YUb50c7052021-01-21 16:02:26 +080041uint32_t commit(const char* name, Entry::Level level)
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050042{
43 auto msg = _prepareMsg("CommitWithLvl");
44 uint64_t id = sdbusplus::server::transaction::get_id();
45 msg.append(id, name, static_cast<uint32_t>(level));
46 auto bus = sdbusplus::bus::new_default();
Lei YUb50c7052021-01-21 16:02:26 +080047 auto reply = bus.call(msg);
48 uint32_t entryID;
49 reply.read(entryID);
50 return entryID;
Adriana Kobylakc20dae82017-02-15 13:44:16 -060051}
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050052} // namespace details
53
Lei YUb50c7052021-01-21 16:02:26 +080054uint32_t commit(std::string&& name)
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050055{
56 log<level::ERR>("method is deprecated, use commit() with exception type");
Lei YUb50c7052021-01-21 16:02:26 +080057 return phosphor::logging::details::commit(name.c_str());
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050058}
Adriana Kobylakc20dae82017-02-15 13:44:16 -060059
60} // namespace logging
61} // namespace phosphor