1 #include "config.h" 2 3 #include <phosphor-logging/elog.hpp> 4 #include <phosphor-logging/lg2.hpp> 5 6 #include <stdexcept> 7 8 namespace phosphor 9 { 10 namespace logging 11 { 12 namespace details 13 { 14 using namespace sdbusplus::server::xyz::openbmc_project::logging; 15 16 auto _prepareMsg(const char* funcName) 17 { 18 using phosphor::logging::log; 19 constexpr auto IFACE_INTERNAL( 20 "xyz.openbmc_project.Logging.Internal.Manager"); 21 22 // Transaction id is located at the end of the string separated by a period. 23 24 auto b = sdbusplus::bus::new_default(); 25 26 auto m = b.new_method_call(BUSNAME_LOGGING, OBJ_INTERNAL, IFACE_INTERNAL, 27 funcName); 28 return m; 29 } 30 31 uint32_t commit(const char* name) 32 { 33 auto msg = _prepareMsg("Commit"); 34 uint64_t id = sdbusplus::server::transaction::get_id(); 35 msg.append(id, name); 36 auto bus = sdbusplus::bus::new_default(); 37 auto reply = bus.call(msg); 38 uint32_t entryID; 39 reply.read(entryID); 40 return entryID; 41 } 42 43 uint32_t commit(const char* name, Entry::Level level) 44 { 45 auto msg = _prepareMsg("CommitWithLvl"); 46 uint64_t id = sdbusplus::server::transaction::get_id(); 47 msg.append(id, name, static_cast<uint32_t>(level)); 48 auto bus = sdbusplus::bus::new_default(); 49 auto reply = bus.call(msg); 50 uint32_t entryID; 51 reply.read(entryID); 52 return entryID; 53 } 54 } // namespace details 55 56 uint32_t commit(std::string&& name) 57 { 58 lg2::error("method is deprecated, use commit() with exception type"); 59 return phosphor::logging::details::commit(name.c_str()); 60 } 61 62 } // namespace logging 63 } // namespace phosphor 64