Skip to content

Commit

Permalink
main: Hide log messages by default when using json output mode
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Detsch <[email protected]>
  • Loading branch information
detsch committed Aug 26, 2024
1 parent 1139ec1 commit 835ecb1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ bpo::variables_map parse_options(int argc, char** argv) {
#endif
("interval", bpo::value<uint64_t>(), "Override uptane.polling_secs interval to poll for update when in daemon mode.")
("command", bpo::value<std::string>(), subs.c_str())
("json", bpo::value<bool>(), "Output targets information as json ('check' and 'list' commands only)");
("json", bpo::value<bool>(), "Output targets information as json ('check' and 'list' commands only).");
// clang-format on

// consider the first positional argument as the aktualizr run mode
Expand Down Expand Up @@ -280,6 +280,13 @@ int main(int argc, char* argv[]) {

int ret_val = EXIT_FAILURE;
try {
// When enabling json output mode, hide log messages by default
if (commandline_map.count("json") > 0 && commandline_map.at("json").as<bool>() &&
commandline_map.count("loglevel") == 0) {
commandline_map.insert(std::pair<std::string, boost::program_options::variable_value>(
"loglevel", boost::program_options::variable_value(static_cast<int>(boost::log::trivial::fatal), false)));
}

Config config(commandline_map);

if (geteuid() != 0) {
Expand Down

0 comments on commit 835ecb1

Please sign in to comment.