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/log_manager.cpp b/log_manager.cpp
index 756ee4f..8fca0a9 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -66,17 +66,19 @@
return infoErrors.size();
}
-void Manager::commit(uint64_t transactionId, std::string errMsg)
+uint32_t Manager::commit(uint64_t transactionId, std::string errMsg)
{
auto level = getLevel(errMsg);
_commit(transactionId, std::move(errMsg), level);
+ return entryId;
}
-void Manager::commitWithLvl(uint64_t transactionId, std::string errMsg,
- uint32_t errLvl)
+uint32_t Manager::commitWithLvl(uint64_t transactionId, std::string errMsg,
+ uint32_t errLvl)
{
_commit(transactionId, std::move(errMsg),
static_cast<Entry::Level>(errLvl));
+ return entryId;
}
void Manager::_commit(uint64_t transactionId, std::string&& errMsg,