blob: 6924c3400c2c6994f68c81c5d9b6403b147b08c2 [file] [log] [blame]
Amithash Prasadeaa501f2025-01-23 15:37:13 -08001#include <CLI/CLI.hpp>
2#include <phosphor-logging/commit.hpp>
Patrick Williamsa282ca62025-07-07 17:07:52 -04003#include <xyz/openbmc_project/Logging/Entry/common.hpp>
Amithash Prasadeaa501f2025-01-23 15:37:13 -08004
5#include <iostream>
6#include <string>
7
Patrick Williamsa282ca62025-07-07 17:07:52 -04008using Interface = sdbusplus::common::xyz::openbmc_project::logging::Entry;
Amithash Prasadeaa501f2025-01-23 15:37:13 -08009
10int main(int argc, char** argv)
11{
12 CLI::App app{"log-resolve"};
13
14 size_t id = 0;
15 std::string path{};
16 auto logIdGroup = app.add_option_group("Log Identifier");
17 auto idOpt = logIdGroup->add_option("-i,--id", id, "Log Entry index");
18 auto pathOpt =
19 logIdGroup->add_option("-p,--path", path, "DBus path of the log entry");
20 logIdGroup->require_option(1);
21
22 CLI11_PARSE(app, argc, argv);
23
24 try
25 {
26 if (*idOpt)
27 {
Patrick Williamsa282ca62025-07-07 17:07:52 -040028 path = std::string(Interface::namespace_path::value) + "/" +
29 std::string(Interface::namespace_path::entry) + "/" +
Amithash Prasadeaa501f2025-01-23 15:37:13 -080030 std::to_string(id);
31 lg2::resolve(path);
32 }
33 else if (*pathOpt)
34 {
35 lg2::resolve(path);
36 }
37 }
38 catch (std::exception& e)
39 {
40 std::cerr << "Unable to resolve: " << e.what() << std::endl;
41 return 1;
42 }
43 return 0;
44}