blob: 11daee76c76958ada85ce8b7dd981983114ba740 [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>
Patrick Williams2544b412022-10-04 08:41:06 -05004
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -05005#include <stdexcept>
Adriana Kobylakc20dae82017-02-15 13:44:16 -06006
7namespace phosphor
8{
9namespace logging
10{
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050011namespace details
Adriana Kobylakc20dae82017-02-15 13:44:16 -060012{
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050013using namespace sdbusplus::xyz::openbmc_project::Logging::server;
14
15auto _prepareMsg(const char* funcName)
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050016{
17 using phosphor::logging::log;
Patrick Venturef18bf832018-10-26 18:14:00 -070018 constexpr auto IFACE_INTERNAL(
19 "xyz.openbmc_project.Logging.Internal.Manager");
Adriana Kobylak205b1132017-02-06 20:15:29 -060020
21 // Transaction id is located at the end of the string separated by a period.
22
23 auto b = sdbusplus::bus::new_default();
Adriana Kobylak205b1132017-02-06 20:15:29 -060024
Matt Spinler6b300d22020-07-15 13:20:44 -050025 auto m = b.new_method_call(BUSNAME_LOGGING, OBJ_INTERNAL, IFACE_INTERNAL,
26 funcName);
Patrick Venturef18bf832018-10-26 18:14:00 -070027 return m;
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050028}
29
Lei YUb50c7052021-01-21 16:02:26 +080030uint32_t commit(const char* name)
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050031{
32 auto msg = _prepareMsg("Commit");
Adriana Kobylak205b1132017-02-06 20:15:29 -060033 uint64_t id = sdbusplus::server::transaction::get_id();
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050034 msg.append(id, name);
35 auto bus = sdbusplus::bus::new_default();
Lei YUb50c7052021-01-21 16:02:26 +080036 auto reply = bus.call(msg);
37 uint32_t entryID;
38 reply.read(entryID);
39 return entryID;
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050040}
41
Lei YUb50c7052021-01-21 16:02:26 +080042uint32_t commit(const char* name, Entry::Level level)
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050043{
44 auto msg = _prepareMsg("CommitWithLvl");
45 uint64_t id = sdbusplus::server::transaction::get_id();
46 msg.append(id, name, static_cast<uint32_t>(level));
47 auto bus = sdbusplus::bus::new_default();
Lei YUb50c7052021-01-21 16:02:26 +080048 auto reply = bus.call(msg);
49 uint32_t entryID;
50 reply.read(entryID);
51 return entryID;
Adriana Kobylakc20dae82017-02-15 13:44:16 -060052}
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050053} // namespace details
54
Lei YUb50c7052021-01-21 16:02:26 +080055uint32_t commit(std::string&& name)
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050056{
57 log<level::ERR>("method is deprecated, use commit() with exception type");
Lei YUb50c7052021-01-21 16:02:26 +080058 return phosphor::logging::details::commit(name.c_str());
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050059}
Adriana Kobylakc20dae82017-02-15 13:44:16 -060060
61} // namespace logging
62} // namespace phosphor