[Orxonox-commit 3842] r8518 - in code/branches/unity_build/src/libraries: core core/command util

rgrieder at orxonox.net rgrieder at orxonox.net
Fri May 20 05:24:53 CEST 2011


Author: rgrieder
Date: 2011-05-20 05:24:52 +0200 (Fri, 20 May 2011)
New Revision: 8518

Modified:
   code/branches/unity_build/src/libraries/core/Core.cc
   code/branches/unity_build/src/libraries/core/Core.h
   code/branches/unity_build/src/libraries/core/command/Shell.cc
   code/branches/unity_build/src/libraries/core/command/Shell.h
   code/branches/unity_build/src/libraries/util/Debug.h
   code/branches/unity_build/src/libraries/util/OutputHandler.cc
   code/branches/unity_build/src/libraries/util/OutputHandler.h
Log:
Sorted out log level handling on startup and transferred its control back to Core.

Modified: code/branches/unity_build/src/libraries/core/Core.cc
===================================================================
--- code/branches/unity_build/src/libraries/core/Core.cc	2011-05-20 03:18:08 UTC (rev 8517)
+++ code/branches/unity_build/src/libraries/core/Core.cc	2011-05-20 03:24:52 UTC (rev 8518)
@@ -231,18 +231,40 @@
         safeObjectDelete(&pathConfig_);
     }
 
+    namespace DefaultLogLevels
+    {
+        struct List
+        {
+            OutputLevel::Value logFile;
+            OutputLevel::Value ioConsole;
+            OutputLevel::Value inGameConsole;
+        };
+
+        using namespace OutputLevel;
+        static const List Dev  = { Debug, Info,  Info  };
+        static const List User = { Info,  Error, Error };
+    }
+
     //! Function to collect the SetConfigValue-macro calls.
     void Core::setConfigValues()
     {
-#ifdef ORXONOX_RELEASE
-        const unsigned int defaultLevelLogFile = 3;
-#else
-        const unsigned int defaultLevelLogFile = 4;
-#endif
-        SetConfigValueExternal(softDebugLevelLogFile_, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile)
-            .description("The maximum level of debug output shown in the log file");
-        OutputHandler::getInstance().setSoftDebugLevel("LogFile", this->softDebugLevelLogFile_);
+        // Choose the default levels according to the path Orxonox was started (build directory or not)
+        DefaultLogLevels::List defaultLogLevels = (PathConfig::buildDirectoryRun() ? DefaultLogLevels::Dev : DefaultLogLevels::User);
 
+        SetConfigValueExternal(debugLevelLogFile_, "OutputHandler", "debugLevelLogFile_", defaultLogLevels.logFile)
+            .description("The maximum level of debug output written to the log file");
+        OutputHandler::getInstance().setSoftDebugLevel("LogFile", debugLevelLogFile_);
+
+        SetConfigValueExternal(debugLevelIOConsole_, "OutputHandler", "debugLevelIOConsole_", defaultLogLevels.ioConsole)
+            .description("The maximum level of debug output shown in the IO console");
+        OutputHandler::getInstance().setSoftDebugLevel("IOConsole", debugLevelIOConsole_);
+        // In case we don't start the IOConsole, also configure that simple listener
+        OutputHandler::getInstance().setSoftDebugLevel("Console", debugLevelIOConsole_);
+
+        SetConfigValueExternal(debugLevelIOConsole_, "OutputHandler", "debugLevelInGameConsole_", defaultLogLevels.inGameConsole)
+            .description("The maximum level of debug output shown in the in-game console");
+        OutputHandler::getInstance().setSoftDebugLevel("InGameConsole", debugLevelInGameConsole_);
+
         SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
             .description("Developer mode. If not set, hides some things from the user to not confuse him.");
         SetConfigValue(language_, Language::getInstance().defaultLanguage_)

Modified: code/branches/unity_build/src/libraries/core/Core.h
===================================================================
--- code/branches/unity_build/src/libraries/core/Core.h	2011-05-20 03:18:08 UTC (rev 8517)
+++ code/branches/unity_build/src/libraries/core/Core.h	2011-05-20 03:24:52 UTC (rev 8518)
@@ -127,7 +127,9 @@
             Scope<ScopeID::Graphics>* graphicsScope_;
 
             bool                      bGraphicsLoaded_;
-            int                       softDebugLevelLogFile_;      //!< The debug level for the log file (belongs to OutputHandler)
+            int                       debugLevelLogFile_;          //!< The debug level for the log file (belongs to OutputHandler)
+            int                       debugLevelIOConsole_;        //!< The debug level for the IO console (belongs to OutputHandler)
+            int                       debugLevelInGameConsole_;    //!< The debug level for the in game console (belongs to OutputHandler)
             std::string               language_;                   //!< The language
             bool                      bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
             bool                      bStartIOConsole_;            //!< Set to false if you don't want to use the IOConsole

Modified: code/branches/unity_build/src/libraries/core/command/Shell.cc
===================================================================
--- code/branches/unity_build/src/libraries/core/command/Shell.cc	2011-05-20 03:18:08 UTC (rev 8517)
+++ code/branches/unity_build/src/libraries/core/command/Shell.cc	2011-05-20 03:24:52 UTC (rev 8518)
@@ -117,15 +117,6 @@
             .callback(this, &Shell::commandHistoryOffsetChanged);
         setConfigValueGeneric(this, &commandHistory_, ConfigFileType::CommandHistory, "Shell", "commandHistory_", std::vector<std::string>());
         SetConfigValue(cacheSize_s, 32);
-
-#ifdef ORXONOX_RELEASE
-        const unsigned int defaultLevel = 1;
-#else
-        const unsigned int defaultLevel = 3;
-#endif
-        SetConfigValueExternal(softDebugLevel_, "OutputHandler", "softDebugLevel" + this->consoleName_, defaultLevel)
-            .description("The maximal level of debug output shown in the Shell");
-        this->setSoftDebugLevel(this->softDebugLevel_);
     }
 
     /**

Modified: code/branches/unity_build/src/libraries/core/command/Shell.h
===================================================================
--- code/branches/unity_build/src/libraries/core/command/Shell.h	2011-05-20 03:18:08 UTC (rev 8517)
+++ code/branches/unity_build/src/libraries/core/command/Shell.h	2011-05-20 03:24:52 UTC (rev 8518)
@@ -196,7 +196,6 @@
             unsigned int              maxHistoryLength_;    ///< The maximum number of saved commands
             unsigned int              historyOffset_;       ///< The command history is a circular buffer, this variable defines the current write-offset
             std::vector<std::string>  commandHistory_;      ///< The history of commands that were entered by the user
-            int                       softDebugLevel_;      ///< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
             static unsigned int       cacheSize_s;          ///< The maximum cache size of the CommandExecutor - this is stored here for better readability of the config file and because CommandExecutor is no OrxonoxClass
     };
 }

Modified: code/branches/unity_build/src/libraries/util/Debug.h
===================================================================
--- code/branches/unity_build/src/libraries/util/Debug.h	2011-05-20 03:18:08 UTC (rev 8517)
+++ code/branches/unity_build/src/libraries/util/Debug.h	2011-05-20 03:24:52 UTC (rev 8518)
@@ -82,8 +82,6 @@
     // Adjust this to discard certain output with level > hardDebugLevel at compile time already
 #ifdef ORXONOX_RELEASE
     const int hardDebugLevel = OutputLevel::Verbose;
-#elif defined(NDEBUG)
-    const int hardDebugLevel = OutputLevel::Verbose;
 #else
     //! Maximum level for debug output that should be even processed at run time
     const int hardDebugLevel = OutputLevel::Ultra;

Modified: code/branches/unity_build/src/libraries/util/OutputHandler.cc
===================================================================
--- code/branches/unity_build/src/libraries/util/OutputHandler.cc	2011-05-20 03:18:08 UTC (rev 8517)
+++ code/branches/unity_build/src/libraries/util/OutputHandler.cc	2011-05-20 03:24:52 UTC (rev 8518)
@@ -156,7 +156,7 @@
     public:
         //! Only assigns the output stream with std::cout
         ConsoleWriter()
-            : OutputListener("consoleLog")
+            : OutputListener("Console")
         {
             this->outputStream_ = &std::cout;
         }
@@ -214,21 +214,24 @@
     OutputHandler::OutputHandler()
         : outputLevel_(OutputLevel::Verbose)
     {
+        // Note: These levels only concern startup before orxonox.ini is read.
 #ifdef ORXONOX_RELEASE
-        const OutputLevel::Value defaultLevelConsole = OutputLevel::Error;
-        const OutputLevel::Value defaultLevelLogFile = OutputLevel::Info;
+        const OutputLevel::Value initialLevelConsole = OutputLevel::Error;
 #else
-        const OutputLevel::Value defaultLevelConsole = OutputLevel::Info;
-        const OutputLevel::Value defaultLevelLogFile = OutputLevel::Debug;
+        const OutputLevel::Value initialLevelConsole = OutputLevel::Info;
 #endif
+        // Use high log level because we rewrite the log file anyway with the
+        // correct level. But if Orxonox were to crash before that, we might be
+        // grateful to have a high debug level, esp. for releases.
+        const OutputLevel::Value intialLevelLogFile = OutputLevel::Debug;
 
         this->logFile_ = new LogFileWriter();
         // Use default level until we get the configValue from the Core
-        this->logFile_->softDebugLevel_ = defaultLevelLogFile;
+        this->logFile_->softDebugLevel_ = intialLevelLogFile;
         this->registerOutputListener(this->logFile_);
 
         this->consoleWriter_ = new ConsoleWriter();
-        this->consoleWriter_->softDebugLevel_ = defaultLevelConsole;
+        this->consoleWriter_->softDebugLevel_ = initialLevelConsole;
         this->registerOutputListener(this->consoleWriter_);
 
         this->memoryBuffer_ = new MemoryLogWriter();

Modified: code/branches/unity_build/src/libraries/util/OutputHandler.h
===================================================================
--- code/branches/unity_build/src/libraries/util/OutputHandler.h	2011-05-20 03:18:08 UTC (rev 8517)
+++ code/branches/unity_build/src/libraries/util/OutputHandler.h	2011-05-20 03:24:52 UTC (rev 8518)
@@ -256,12 +256,6 @@
         const std::string& getOutputListenerName() const { return this->name_; }
         //! Returns the soft debug level of the listener
         int getSoftDebugLevel() const { return this->softDebugLevel_; }
-        //! Sets the soft debug level of the listener
-        void setSoftDebugLevel(int level)
-        {
-            this->softDebugLevel_ = level;
-            OutputHandler::getInstance().setSoftDebugLevel(this->name_, level);
-        }
 
     protected:
         std::ostream*     outputStream_;   //!< Pointer to the associated output stream, can be NULL




More information about the Orxonox-commit mailing list