blob: 012006e65c7e912b04480c26e50f32d6d51826cf [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>
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -05004#include <stdexcept>
Adriana Kobylakc20dae82017-02-15 13:44:16 -06005
6namespace phosphor
7{
8namespace logging
9{
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050010namespace details
Adriana Kobylakc20dae82017-02-15 13:44:16 -060011{
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050012using namespace sdbusplus::xyz::openbmc_project::Logging::server;
13
14auto _prepareMsg(const char* funcName)
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050015{
16 using phosphor::logging::log;
Patrick Venturef18bf832018-10-26 18:14:00 -070017 constexpr auto IFACE_INTERNAL(
18 "xyz.openbmc_project.Logging.Internal.Manager");
Adriana Kobylak205b1132017-02-06 20:15:29 -060019
20 // Transaction id is located at the end of the string separated by a period.
21
22 auto b = sdbusplus::bus::new_default();
Adriana Kobylak205b1132017-02-06 20:15:29 -060023
Matt Spinler6b300d22020-07-15 13:20:44 -050024 auto m = b.new_method_call(BUSNAME_LOGGING, OBJ_INTERNAL, IFACE_INTERNAL,
25 funcName);
Patrick Venturef18bf832018-10-26 18:14:00 -070026 return m;
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050027}
28
29void commit(const char* name)
30{
31 auto msg = _prepareMsg("Commit");
Adriana Kobylak205b1132017-02-06 20:15:29 -060032 uint64_t id = sdbusplus::server::transaction::get_id();
Deepak Kodihalli6fd9dc42018-04-03 02:08:42 -050033 msg.append(id, name);
34 auto bus = sdbusplus::bus::new_default();
35 bus.call_noreply(msg);
36}
37
38void 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 Kobylakc20dae82017-02-15 13:44:16 -060045}
Marri Devender Rao7d0a07b2017-04-04 03:43:00 -050046} // namespace details
47
48void 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 Kobylakc20dae82017-02-15 13:44:16 -060053
54} // namespace logging
55} // namespace phosphor