From 42c66e29eeee1c1e0d7eb4450202fc0493db65e9 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Thu, 19 Mar 2015 14:58:44 +0100 Subject: [PATCH] Allow setting loglevel from commandline --- src/main.cxx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main.cxx b/src/main.cxx index d284d4f..24ddf7a 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -37,11 +37,36 @@ int main(int argc, char** argv) #ifdef ARGPARSE parser.addHelpOption(); parser.addVersionOption(); + + QCommandLineOption loglevelOption("loglevel", "Control verbosity of logging", "FATAL|ERROR|WARN|INFO|DEBUG|TRACE"); + loglevelOption.setDefaultValue("INFO"); + parser.addOption(loglevelOption); + parser.addPositionalArgument("filename", QCoreApplication::translate("main", "File to disassemble.")); parser.process(app); #endif + log4cxx::LevelPtr level = log4cxx::Level::getInfo(); +#ifdef ARGPARSE + if (parser.value(loglevelOption) != "") { + std::string levelstring = parser.value(loglevelOption).toStdString(); + if (levelstring == "FATAL") + level = log4cxx::Level::getFatal(); + if (levelstring == "ERROR") + level = log4cxx::Level::getError(); + if (levelstring == "WARN") + level = log4cxx::Level::getWarn(); + if (levelstring == "INFO") + level = log4cxx::Level::getInfo(); + if (levelstring == "DEBUG") + level = log4cxx::Level::getDebug(); + if (levelstring == "TRACE") + level = log4cxx::Level::getTrace(); + } +#endif + log4cxx::Logger::getRootLogger()->setLevel(level); + InformationManager iman; LOG4CXX_DEBUG(_logger, "Initializing LLVM"); -- 2.39.5