blob: 890fd5d3f3ca0947c75ea51c600f2d2ab7b7f2e8 [file] [log] [blame]
#include "config.h"
#include <phosphor-logging/elog.hpp>
#include <stdexcept>
namespace phosphor
{
namespace logging
{
namespace details
{
using namespace sdbusplus::xyz::openbmc_project::Logging::server;
auto _prepareMsg(const char* funcName)
{
using phosphor::logging::log;
constexpr auto IFACE_INTERNAL(
"xyz.openbmc_project.Logging.Internal.Manager");
// Transaction id is located at the end of the string separated by a period.
auto b = sdbusplus::bus::new_default();
auto m = b.new_method_call(BUSNAME_LOGGING, OBJ_INTERNAL, IFACE_INTERNAL,
funcName);
return m;
}
uint32_t commit(const char* name)
{
auto msg = _prepareMsg("Commit");
uint64_t id = sdbusplus::server::transaction::get_id();
msg.append(id, name);
auto bus = sdbusplus::bus::new_default();
auto reply = bus.call(msg);
uint32_t entryID;
reply.read(entryID);
return entryID;
}
uint32_t commit(const char* name, Entry::Level level)
{
auto msg = _prepareMsg("CommitWithLvl");
uint64_t id = sdbusplus::server::transaction::get_id();
msg.append(id, name, static_cast<uint32_t>(level));
auto bus = sdbusplus::bus::new_default();
auto reply = bus.call(msg);
uint32_t entryID;
reply.read(entryID);
return entryID;
}
} // namespace details
uint32_t commit(std::string&& name)
{
log<level::ERR>("method is deprecated, use commit() with exception type");
return phosphor::logging::details::commit(name.c_str());
}
} // namespace logging
} // namespace phosphor