Deepak Kodihalli | 827b50f | 2017-02-24 00:00:08 -0600 | [diff] [blame] | 1 | #include "config.h" |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 2 | |
Saqib Khan | 2bb1519 | 2017-02-13 13:19:55 -0600 | [diff] [blame] | 3 | #include <phosphor-logging/elog.hpp> |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 4 | #include <stdexcept> |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 5 | |
| 6 | namespace phosphor |
| 7 | { |
| 8 | namespace logging |
| 9 | { |
Marri Devender Rao | 7d0a07b | 2017-04-04 03:43:00 -0500 | [diff] [blame] | 10 | namespace details |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 11 | { |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 12 | using namespace sdbusplus::xyz::openbmc_project::Logging::server; |
| 13 | |
| 14 | auto _prepareMsg(const char* funcName) |
Marri Devender Rao | 7d0a07b | 2017-04-04 03:43:00 -0500 | [diff] [blame] | 15 | { |
| 16 | using phosphor::logging::log; |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 17 | constexpr auto IFACE_INTERNAL( |
| 18 | "xyz.openbmc_project.Logging.Internal.Manager"); |
Adriana Kobylak | 205b113 | 2017-02-06 20:15:29 -0600 | [diff] [blame] | 19 | |
| 20 | // Transaction id is located at the end of the string separated by a period. |
| 21 | |
| 22 | auto b = sdbusplus::bus::new_default(); |
Adriana Kobylak | 205b113 | 2017-02-06 20:15:29 -0600 | [diff] [blame] | 23 | |
Matt Spinler | 6b300d2 | 2020-07-15 13:20:44 -0500 | [diff] [blame] | 24 | auto m = b.new_method_call(BUSNAME_LOGGING, OBJ_INTERNAL, IFACE_INTERNAL, |
| 25 | funcName); |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 26 | return m; |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 27 | } |
| 28 | |
Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 29 | uint32_t commit(const char* name) |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 30 | { |
| 31 | auto msg = _prepareMsg("Commit"); |
Adriana Kobylak | 205b113 | 2017-02-06 20:15:29 -0600 | [diff] [blame] | 32 | uint64_t id = sdbusplus::server::transaction::get_id(); |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 33 | msg.append(id, name); |
| 34 | auto bus = sdbusplus::bus::new_default(); |
Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 35 | auto reply = bus.call(msg); |
| 36 | uint32_t entryID; |
| 37 | reply.read(entryID); |
| 38 | return entryID; |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 39 | } |
| 40 | |
Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 41 | uint32_t commit(const char* name, Entry::Level level) |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 42 | { |
| 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 YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 47 | auto reply = bus.call(msg); |
| 48 | uint32_t entryID; |
| 49 | reply.read(entryID); |
| 50 | return entryID; |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 51 | } |
Marri Devender Rao | 7d0a07b | 2017-04-04 03:43:00 -0500 | [diff] [blame] | 52 | } // namespace details |
| 53 | |
Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 54 | uint32_t commit(std::string&& name) |
Marri Devender Rao | 7d0a07b | 2017-04-04 03:43:00 -0500 | [diff] [blame] | 55 | { |
| 56 | log<level::ERR>("method is deprecated, use commit() with exception type"); |
Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 57 | return phosphor::logging::details::commit(name.c_str()); |
Marri Devender Rao | 7d0a07b | 2017-04-04 03:43:00 -0500 | [diff] [blame] | 58 | } |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 59 | |
| 60 | } // namespace logging |
| 61 | } // namespace phosphor |