From fd30e8ca25b7060f339928dc62d661c3aeab0d00 Mon Sep 17 00:00:00 2001 From: gereon Date: Fri, 15 Mar 2013 12:52:20 +0100 Subject: [PATCH] Cleaned up handling of --verbose, proposing correct use of log levels from now on... FATAL_LOG_LEVEL: Use, if we are going to crash. ERROR_LOG_LEVEL: Use, if there is no reasonable way to continue. WARN_LOG_LEVEL: Use, if we got something the average user should read. INFO_LOG_LEVEL: Use, if this might in some cases be of interest. DEBUG_LOG_LEVEL: Use, if this should usually not be relevant to a user. TRACE_LOG_LEVEL: Use only during development. There are three levels of verbosity: - default: WARN and above - verbose: INFO and above - debug: DEBUG and above --- src/storm.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/storm.cpp b/src/storm.cpp index 55819560b..2fc723034 100644 --- a/src/storm.cpp +++ b/src/storm.cpp @@ -48,7 +48,7 @@ log4cplus::Logger logger; */ void initializeLogger() { logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("main")); - logger.setLogLevel(log4cplus::INFO_LOG_LEVEL); + logger.setLogLevel(log4cplus::WARN_LOG_LEVEL); log4cplus::SharedAppenderPtr consoleLogAppender(new log4cplus::ConsoleAppender()); consoleLogAppender->setName("mainConsoleAppender"); consoleLogAppender->setLayout(std::auto_ptr(new log4cplus::PatternLayout("%-5p - %D{%H:%M:%S} (%r ms) - %b:%L: %m%n"))); @@ -115,18 +115,17 @@ bool parseOptions(const int argc, const char* argv[]) { return false; } - if (!s->isSet("verbose") && !s->isSet("logfile")) { - logger.setLogLevel(log4cplus::FATAL_LOG_LEVEL); - } else if (!s->isSet("verbose")) { - logger.removeAppender("mainConsoleAppender"); - setUpFileLogging(); - } else if (!s->isSet("logfile")) { + if (s->isSet("verbose")) { + logger.setLogLevel(log4cplus::INFO_LOG_LEVEL); LOG4CPLUS_INFO(logger, "Enable verbose mode, log output gets printed to console."); - } else { + } + if (s->isSet("debug")) { + logger.setLogLevel(log4cplus::DEBUG_LOG_LEVEL); + LOG4CPLUS_INFO(logger, "Enable very verbose mode, log output gets printed to console."); + } + if (s->isSet("logfile")) { setUpFileLogging(); - LOG4CPLUS_INFO(logger, "Enable verbose mode, log output gets printed to console."); } - return true; }