]> git.siccegge.de Git - frida/frida.git/commitdiff
Allow setting loglevel from commandline
authorChristoph Egger <Christoph.Egger@fau.de>
Thu, 19 Mar 2015 13:58:44 +0000 (14:58 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Thu, 19 Mar 2015 13:58:44 +0000 (14:58 +0100)
src/main.cxx

index d284d4fcb0a3e685d797877182465505f9bb25a7..24ddf7a2ad24aca695601d0d6b8d0906b4a5350e 100644 (file)
@@ -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");