From 2a399fc7c20bd321bcbb66f2746b19444cc2641a Mon Sep 17 00:00:00 2001 From: Kyle Benne Date: Fri, 10 Nov 2023 16:16:42 -0600 Subject: [PATCH] Revert "Remove --verbose in labs CLI: -l / --loglevel from #4919 is enough" This reverts commit fada36ffed6586445a0d57aeac761fc62070a35b. --- src/cli/main.cpp | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/cli/main.cpp b/src/cli/main.cpp index 60f72d70f8f..7ae614118b8 100644 --- a/src/cli/main.cpp +++ b/src/cli/main.cpp @@ -108,6 +108,19 @@ int main(int argc, char* argv[]) { app.get_formatter()->column_width(35); + auto* const verboseOpt = app.add_flag_function( + "--verbose", + [](auto count) { + if (count == 1) { + fmt::print("Setting Log Level to Debug ({})\n", LogLevel::Debug); + openstudio::Logger::instance().standardOutLogger().setLogLevel(LogLevel::Debug); + } else if (count == 2) { + fmt::print("Setting Log Level to Trace ({})\n", LogLevel::Trace); + openstudio::Logger::instance().standardOutLogger().setLogLevel(LogLevel::Trace); + } + }, + "Print the full log to STDOUT - sets verbosity to Debug if given once and Trace if given twice."); + // specify string->value mappings const std::map logLevelMap{ {"Trace", LogLevel::Trace}, {"Debug", LogLevel::Debug}, {"Info", LogLevel::Info}, @@ -115,16 +128,21 @@ int main(int argc, char* argv[]) { }; static constexpr std::array logLevelStrs = {"Trace", "Debug", "Info", "Warn", "Error", "Fatal"}; - app - .add_option_function( - "-l,--loglevel", - [](const LogLevel& level) { - fmt::print("Setting Log Level to {} ({})\n", logLevelStrs[static_cast(level) - static_cast(LogLevel::Trace)], std::to_string(level)); - openstudio::Logger::instance().standardOutLogger().setLogLevel(level); - }, - "LogLevel settings: One of {Trace, Debug, Info, Warn, Error, Fatal} [Default: Warn]") - ->option_text("LEVEL") - ->transform(CLI::CheckedTransformer(logLevelMap, CLI::ignore_case)); + auto* const logLevelOpt = + app + .add_option_function( + "-l,--loglevel", + [](const LogLevel& level) { + fmt::print("Setting Log Level to {} ({})\n", logLevelStrs[static_cast(level) - static_cast(LogLevel::Trace)], + std::to_string(level)); + openstudio::Logger::instance().standardOutLogger().setLogLevel(level); + }, + "LogLevel settings: One of {Trace, Debug, Info, Warn, Error, Fatal} [Default: Warn] Excludes: --verbose") + ->excludes(verboseOpt) + ->option_text("LEVEL") + ->transform(CLI::CheckedTransformer(logLevelMap, CLI::ignore_case)); + + verboseOpt->excludes(logLevelOpt); std::vector executeRubyCmds; CLI::Option* execRubyOption = app