Return entryID on commiting logs
Let the Commit()/CommitWithLvl() methods return entryID, so that the
caller of commit()/report() could get the entryID directly without
querying the logging service again.
This is useful in cases that the caller needs to know the entryID of the
commit()/report() events.
Tested: Manually verify the report() returns the correct entryID.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: Ieb22d32d4e9242ec46b799f6e98ca3d49e7590b9
diff --git a/elog.cpp b/elog.cpp
index 012006e..890fd5d 100644
--- a/elog.cpp
+++ b/elog.cpp
@@ -26,29 +26,35 @@
return m;
}
-void commit(const char* name)
+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();
- bus.call_noreply(msg);
+ auto reply = bus.call(msg);
+ uint32_t entryID;
+ reply.read(entryID);
+ return entryID;
}
-void commit(const char* name, Entry::Level level)
+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();
- bus.call_noreply(msg);
+ auto reply = bus.call(msg);
+ uint32_t entryID;
+ reply.read(entryID);
+ return entryID;
}
} // namespace details
-void commit(std::string&& name)
+uint32_t commit(std::string&& name)
{
log<level::ERR>("method is deprecated, use commit() with exception type");
- phosphor::logging::details::commit(name.c_str());
+ return phosphor::logging::details::commit(name.c_str());
}
} // namespace logging