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