Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 21, 2011, 4:23:19 AM (13 years ago)
Author:
rgrieder
Message:

Fixed a serious problem with the debug levels for the Shells by introducing DevModeListener and moving the debug levels to the Shell again..

File:
1 edited

Legend:

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

    r8520 r8524  
    6969#include "Language.h"
    7070#include "LuaState.h"
     71#include "ObjectList.h"
    7172#include "command/ConsoleCommand.h"
    7273#include "command/IOConsole.h"
     
    229230    }
    230231
    231     namespace DefaultLogLevels
    232     {
    233         struct List
    234         {
    235             OutputLevel::Value logFile;
    236             OutputLevel::Value ioConsole;
    237             OutputLevel::Value inGameConsole;
    238         };
    239 
    240         using namespace OutputLevel;
    241         static const List Dev  = { Debug, Info,  Info  };
    242         static const List User = { Info,  Error, Error };
     232    namespace DefaultLevelLogFile
     233    {
     234        const OutputLevel::Value Dev  = OutputLevel::Debug;
     235        const OutputLevel::Value User = OutputLevel::Info;
    243236    }
    244237
     
    246239    void Core::setConfigValues()
    247240    {
    248         // Choose the default levels according to the path Orxonox was started (build directory or not)
    249         DefaultLogLevels::List defaultLogLevels = (PathConfig::buildDirectoryRun() ? DefaultLogLevels::Dev : DefaultLogLevels::User);
    250 
    251         SetConfigValueExternal(debugLevelLogFile_, "OutputHandler", "debugLevelLogFile_", defaultLogLevels.logFile)
     241        // Choose the default level according to the path Orxonox was started (build directory or not)
     242        OutputLevel::Value defaultLogLevel = (PathConfig::buildDirectoryRun() ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);
     243
     244        SetConfigValueExternal(debugLevelLogFile_, "OutputHandler", "debugLevelLogFile", defaultLogLevel)
    252245            .description("The maximum level of debug output written to the log file");
    253246        OutputHandler::getInstance().setSoftDebugLevel("LogFile", debugLevelLogFile_);
    254 
    255         SetConfigValueExternal(debugLevelIOConsole_, "OutputHandler", "debugLevelIOConsole_", defaultLogLevels.ioConsole)
    256             .description("The maximum level of debug output shown in the IO console");
    257         OutputHandler::getInstance().setSoftDebugLevel("IOConsole", debugLevelIOConsole_);
    258         // In case we don't start the IOConsole, also configure that simple listener
    259         OutputHandler::getInstance().setSoftDebugLevel("Console", debugLevelIOConsole_);
    260 
    261         SetConfigValueExternal(debugLevelIOConsole_, "OutputHandler", "debugLevelInGameConsole_", defaultLogLevels.inGameConsole)
    262             .description("The maximum level of debug output shown in the in-game console");
    263         OutputHandler::getInstance().setSoftDebugLevel("InGameConsole", debugLevelInGameConsole_);
    264247
    265248        SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
     
    290273          immediately change the debug levels to predefined values which can be
    291274          reconfigured with \c tconfig.
     275    @note
     276        The debug levels for the IOConsole and the InGameConsole can be found
     277        in the Shell class. The same rules apply.
    292278    */
    293279    void Core::devModeChanged()
     
    296282        if (isNormal)
    297283        {
    298             ModifyConfigValue(debugLevelLogFile_,       update);
    299             ModifyConfigValue(debugLevelIOConsole_,     update);
    300             ModifyConfigValue(debugLevelInGameConsole_, update);
     284            ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", update);
    301285        }
    302286        else
    303287        {
    304             DefaultLogLevels::List levels = (bDevMode_ ? DefaultLogLevels::Dev : DefaultLogLevels::User);
    305             ModifyConfigValue(debugLevelLogFile_,       tset, levels.logFile);
    306             ModifyConfigValue(debugLevelIOConsole_,     tset, levels.ioConsole);
    307             ModifyConfigValue(debugLevelInGameConsole_, tset, levels.inGameConsole);
    308         }
     288            OutputLevel::Value level = (bDevMode_ ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);
     289            ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", tset, level);
     290        }
     291
     292        // Inform listeners
     293        ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin();
     294        for (; it != ObjectList<DevModeListener>::end(); ++it)
     295            it->devModeChanged(bDevMode_);
    309296    }
    310297
     
    491478        ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));
    492479    }
     480
     481
     482    DevModeListener::DevModeListener()
     483    {
     484        RegisterRootObject(DevModeListener);
     485    }
    493486}
Note: See TracChangeset for help on using the changeset viewer.