1eaa501f3SAmithash Prasad #include <CLI/CLI.hpp>
2eaa501f3SAmithash Prasad #include <phosphor-logging/commit.hpp>
3*a282ca61SPatrick Williams #include <xyz/openbmc_project/Logging/Entry/common.hpp>
4eaa501f3SAmithash Prasad
5eaa501f3SAmithash Prasad #include <iostream>
6eaa501f3SAmithash Prasad #include <string>
7eaa501f3SAmithash Prasad
8*a282ca61SPatrick Williams using Interface = sdbusplus::common::xyz::openbmc_project::logging::Entry;
9eaa501f3SAmithash Prasad
main(int argc,char ** argv)10eaa501f3SAmithash Prasad int main(int argc, char** argv)
11eaa501f3SAmithash Prasad {
12eaa501f3SAmithash Prasad CLI::App app{"log-resolve"};
13eaa501f3SAmithash Prasad
14eaa501f3SAmithash Prasad size_t id = 0;
15eaa501f3SAmithash Prasad std::string path{};
16eaa501f3SAmithash Prasad auto logIdGroup = app.add_option_group("Log Identifier");
17eaa501f3SAmithash Prasad auto idOpt = logIdGroup->add_option("-i,--id", id, "Log Entry index");
18eaa501f3SAmithash Prasad auto pathOpt =
19eaa501f3SAmithash Prasad logIdGroup->add_option("-p,--path", path, "DBus path of the log entry");
20eaa501f3SAmithash Prasad logIdGroup->require_option(1);
21eaa501f3SAmithash Prasad
22eaa501f3SAmithash Prasad CLI11_PARSE(app, argc, argv);
23eaa501f3SAmithash Prasad
24eaa501f3SAmithash Prasad try
25eaa501f3SAmithash Prasad {
26eaa501f3SAmithash Prasad if (*idOpt)
27eaa501f3SAmithash Prasad {
28*a282ca61SPatrick Williams path = std::string(Interface::namespace_path::value) + "/" +
29*a282ca61SPatrick Williams std::string(Interface::namespace_path::entry) + "/" +
30eaa501f3SAmithash Prasad std::to_string(id);
31eaa501f3SAmithash Prasad lg2::resolve(path);
32eaa501f3SAmithash Prasad }
33eaa501f3SAmithash Prasad else if (*pathOpt)
34eaa501f3SAmithash Prasad {
35eaa501f3SAmithash Prasad lg2::resolve(path);
36eaa501f3SAmithash Prasad }
37eaa501f3SAmithash Prasad }
38eaa501f3SAmithash Prasad catch (std::exception& e)
39eaa501f3SAmithash Prasad {
40eaa501f3SAmithash Prasad std::cerr << "Unable to resolve: " << e.what() << std::endl;
41eaa501f3SAmithash Prasad return 1;
42eaa501f3SAmithash Prasad }
43eaa501f3SAmithash Prasad return 0;
44eaa501f3SAmithash Prasad }
45