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 | |
| 29 | void commit(const char* name) |
| 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(); |
| 35 | bus.call_noreply(msg); |
| 36 | } |
| 37 | |
| 38 | void commit(const char* name, Entry::Level level) |
| 39 | { |
| 40 | auto msg = _prepareMsg("CommitWithLvl"); |
| 41 | uint64_t id = sdbusplus::server::transaction::get_id(); |
| 42 | msg.append(id, name, static_cast<uint32_t>(level)); |
| 43 | auto bus = sdbusplus::bus::new_default(); |
| 44 | bus.call_noreply(msg); |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 45 | } |
Marri Devender Rao | 7d0a07b | 2017-04-04 03:43:00 -0500 | [diff] [blame] | 46 | } // namespace details |
| 47 | |
| 48 | void commit(std::string&& name) |
| 49 | { |
| 50 | log<level::ERR>("method is deprecated, use commit() with exception type"); |
| 51 | phosphor::logging::details::commit(name.c_str()); |
| 52 | } |
Adriana Kobylak | c20dae8 | 2017-02-15 13:44:16 -0600 | [diff] [blame] | 53 | |
| 54 | } // namespace logging |
| 55 | } // namespace phosphor |