Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 20, 2011, 5:24:52 AM (14 years ago)
Author:
rgrieder
Message:

Sorted out log level handling on startup and transferred its control back to Core.

Location:
code/branches/unity_build/src/libraries
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/unity_build/src/libraries/core/Core.cc

    r8517 r8518  
    232232    }
    233233
     234    namespace DefaultLogLevels
     235    {
     236        struct List
     237        {
     238            OutputLevel::Value logFile;
     239            OutputLevel::Value ioConsole;
     240            OutputLevel::Value inGameConsole;
     241        };
     242
     243        using namespace OutputLevel;
     244        static const List Dev  = { Debug, Info,  Info  };
     245        static const List User = { Info,  Error, Error };
     246    }
     247
    234248    //! Function to collect the SetConfigValue-macro calls.
    235249    void Core::setConfigValues()
    236250    {
    237 #ifdef ORXONOX_RELEASE
    238         const unsigned int defaultLevelLogFile = 3;
    239 #else
    240         const unsigned int defaultLevelLogFile = 4;
    241 #endif
    242         SetConfigValueExternal(softDebugLevelLogFile_, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile)
    243             .description("The maximum level of debug output shown in the log file");
    244         OutputHandler::getInstance().setSoftDebugLevel("LogFile", this->softDebugLevelLogFile_);
     251        // Choose the default levels according to the path Orxonox was started (build directory or not)
     252        DefaultLogLevels::List defaultLogLevels = (PathConfig::buildDirectoryRun() ? DefaultLogLevels::Dev : DefaultLogLevels::User);
     253
     254        SetConfigValueExternal(debugLevelLogFile_, "OutputHandler", "debugLevelLogFile_", defaultLogLevels.logFile)
     255            .description("The maximum level of debug output written to the log file");
     256        OutputHandler::getInstance().setSoftDebugLevel("LogFile", debugLevelLogFile_);
     257
     258        SetConfigValueExternal(debugLevelIOConsole_, "OutputHandler", "debugLevelIOConsole_", defaultLogLevels.ioConsole)
     259            .description("The maximum level of debug output shown in the IO console");
     260        OutputHandler::getInstance().setSoftDebugLevel("IOConsole", debugLevelIOConsole_);
     261        // In case we don't start the IOConsole, also configure that simple listener
     262        OutputHandler::getInstance().setSoftDebugLevel("Console", debugLevelIOConsole_);
     263
     264        SetConfigValueExternal(debugLevelIOConsole_, "OutputHandler", "debugLevelInGameConsole_", defaultLogLevels.inGameConsole)
     265            .description("The maximum level of debug output shown in the in-game console");
     266        OutputHandler::getInstance().setSoftDebugLevel("InGameConsole", debugLevelInGameConsole_);
    245267
    246268        SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
  • code/branches/unity_build/src/libraries/core/Core.h

    r8423 r8518  
    128128
    129129            bool                      bGraphicsLoaded_;
    130             int                       softDebugLevelLogFile_;      //!< The debug level for the log file (belongs to OutputHandler)
     130            int                       debugLevelLogFile_;          //!< The debug level for the log file (belongs to OutputHandler)
     131            int                       debugLevelIOConsole_;        //!< The debug level for the IO console (belongs to OutputHandler)
     132            int                       debugLevelInGameConsole_;    //!< The debug level for the in game console (belongs to OutputHandler)
    131133            std::string               language_;                   //!< The language
    132134            bool                      bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
  • code/branches/unity_build/src/libraries/core/command/Shell.cc

    r8515 r8518  
    118118        setConfigValueGeneric(this, &commandHistory_, ConfigFileType::CommandHistory, "Shell", "commandHistory_", std::vector<std::string>());
    119119        SetConfigValue(cacheSize_s, 32);
    120 
    121 #ifdef ORXONOX_RELEASE
    122         const unsigned int defaultLevel = 1;
    123 #else
    124         const unsigned int defaultLevel = 3;
    125 #endif
    126         SetConfigValueExternal(softDebugLevel_, "OutputHandler", "softDebugLevel" + this->consoleName_, defaultLevel)
    127             .description("The maximal level of debug output shown in the Shell");
    128         this->setSoftDebugLevel(this->softDebugLevel_);
    129120    }
    130121
  • code/branches/unity_build/src/libraries/core/command/Shell.h

    r7401 r8518  
    197197            unsigned int              historyOffset_;       ///< The command history is a circular buffer, this variable defines the current write-offset
    198198            std::vector<std::string>  commandHistory_;      ///< The history of commands that were entered by the user
    199             int                       softDebugLevel_;      ///< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
    200199            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
    201200    };
  • code/branches/unity_build/src/libraries/util/Debug.h

    r7401 r8518  
    8383#ifdef ORXONOX_RELEASE
    8484    const int hardDebugLevel = OutputLevel::Verbose;
    85 #elif defined(NDEBUG)
    86     const int hardDebugLevel = OutputLevel::Verbose;
    8785#else
    8886    //! Maximum level for debug output that should be even processed at run time
  • code/branches/unity_build/src/libraries/util/OutputHandler.cc

    r8517 r8518  
    157157        //! Only assigns the output stream with std::cout
    158158        ConsoleWriter()
    159             : OutputListener("consoleLog")
     159            : OutputListener("Console")
    160160        {
    161161            this->outputStream_ = &std::cout;
     
    215215        : outputLevel_(OutputLevel::Verbose)
    216216    {
     217        // Note: These levels only concern startup before orxonox.ini is read.
    217218#ifdef ORXONOX_RELEASE
    218         const OutputLevel::Value defaultLevelConsole = OutputLevel::Error;
    219         const OutputLevel::Value defaultLevelLogFile = OutputLevel::Info;
     219        const OutputLevel::Value initialLevelConsole = OutputLevel::Error;
    220220#else
    221         const OutputLevel::Value defaultLevelConsole = OutputLevel::Info;
    222         const OutputLevel::Value defaultLevelLogFile = OutputLevel::Debug;
     221        const OutputLevel::Value initialLevelConsole = OutputLevel::Info;
    223222#endif
     223        // Use high log level because we rewrite the log file anyway with the
     224        // correct level. But if Orxonox were to crash before that, we might be
     225        // grateful to have a high debug level, esp. for releases.
     226        const OutputLevel::Value intialLevelLogFile = OutputLevel::Debug;
    224227
    225228        this->logFile_ = new LogFileWriter();
    226229        // Use default level until we get the configValue from the Core
    227         this->logFile_->softDebugLevel_ = defaultLevelLogFile;
     230        this->logFile_->softDebugLevel_ = intialLevelLogFile;
    228231        this->registerOutputListener(this->logFile_);
    229232
    230233        this->consoleWriter_ = new ConsoleWriter();
    231         this->consoleWriter_->softDebugLevel_ = defaultLevelConsole;
     234        this->consoleWriter_->softDebugLevel_ = initialLevelConsole;
    232235        this->registerOutputListener(this->consoleWriter_);
    233236
  • code/branches/unity_build/src/libraries/util/OutputHandler.h

    r8517 r8518  
    257257        //! Returns the soft debug level of the listener
    258258        int getSoftDebugLevel() const { return this->softDebugLevel_; }
    259         //! Sets the soft debug level of the listener
    260         void setSoftDebugLevel(int level)
    261         {
    262             this->softDebugLevel_ = level;
    263             OutputHandler::getInstance().setSoftDebugLevel(this->name_, level);
    264         }
    265259
    266260    protected:
Note: See TracChangeset for help on using the changeset viewer.