Add helper method to resolve a log object path
Add a helper method to resolve a previously generated
log entry which can be used by other services in conjunction
with the `lg2::commit` API.
Change-Id: Ia1582177b51ca2f0bfecae98f999b5b8f2f61c93
Signed-off-by: Amithash Prasasd <amithash@meta.com>
diff --git a/lib/lg2_commit.cpp b/lib/lg2_commit.cpp
index 6916bf5..a35b91e 100644
--- a/lib/lg2_commit.cpp
+++ b/lib/lg2_commit.cpp
@@ -142,6 +142,20 @@
return {};
}
+void resolve(const sdbusplus::message::object_path& logPath)
+{
+ if constexpr (LG2_COMMIT_DBUS)
+ {
+ using details::Entry;
+
+ auto b = sdbusplus::bus::new_default();
+ auto m = b.new_method_call(Entry::default_service, logPath.str.c_str(),
+ "org.freedesktop.DBus.Properties", "Set");
+ m.append(Entry::interface, "Resolved", std::variant<bool>(true));
+ auto reply = b.call(m);
+ }
+}
+
auto commit(sdbusplus::async::context& ctx,
sdbusplus::exception::generated_event_base&& t)
-> sdbusplus::async::task<sdbusplus::message::object_path>
@@ -164,4 +178,21 @@
co_return {};
}
+auto resolve(sdbusplus::async::context& ctx,
+ const sdbusplus::message::object_path& logPath)
+ -> sdbusplus::async::task<>
+{
+ using details::Entry;
+
+ if constexpr (LG2_COMMIT_DBUS)
+ {
+ std::string path = logPath.str;
+ co_await Entry(ctx)
+ .service(Entry::default_service)
+ .path(path)
+ .resolved(true);
+ }
+ co_return;
+}
+
} // namespace lg2