Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 21, 2011, 4:23:19 AM (14 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..

Location:
code/branches/unity_build/src/libraries/core/command
Files:
2 edited

Legend:

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

    r8518 r8524  
    4040#include "core/ConfigFileManager.h"
    4141#include "core/ConfigValueIncludes.h"
     42#include "core/PathConfig.h"
    4243#include "CommandExecutor.h"
    4344#include "ConsoleCommand.h"
     
    8788        for (;it != OutputHandler::getInstance().getOutput().end(); ++it)
    8889        {
    89             if (it->first <= this->getSoftDebugLevel())
     90            if (it->first <= debugLevel_)
    9091            {
    9192                this->outputBuffer_ << it->second;
     
    9697        // Register the shell as output listener
    9798        OutputHandler::getInstance().registerOutputListener(this);
     99        OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_);
    98100    }
    99101
     
    105107        OutputHandler::getInstance().unregisterOutputListener(this);
    106108        this->inputBuffer_->destroy();
     109    }
     110
     111    namespace DefaultLogLevel
     112    {
     113        const OutputLevel::Value Dev  = OutputLevel::Info;
     114        const OutputLevel::Value User = OutputLevel::Error;
    107115    }
    108116
     
    118126        setConfigValueGeneric(this, &commandHistory_, ConfigFileType::CommandHistory, "Shell", "commandHistory_", std::vector<std::string>());
    119127        SetConfigValue(cacheSize_s, 32);
     128
     129        // Choose the default level according to the path Orxonox was started (build directory or not)
     130        OutputLevel::Value defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);
     131        SetConfigValueExternal(debugLevel_, "OutputHandler", "debugLevel" + consoleName_, defaultDebugLevel)
     132            .description("The maximum level of debug output shown in the " + consoleName_);
     133        OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_);
    120134    }
    121135
     
    141155            this->commandHistory_.erase(this->commandHistory_.begin() + index);
    142156            ModifyConfigValue(commandHistory_, remove, index);
     157        }
     158    }
     159
     160    /** Called upon changes in the development mode (by Core)
     161        Behaviour details see Core::devModeChanged.
     162    */
     163    void Shell::devModeChanged(bool value)
     164    {
     165        bool isNormal = (value == PathConfig::buildDirectoryRun());
     166        if (isNormal)
     167        {
     168            ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, update);
     169        }
     170        else
     171        {
     172            OutputLevel::Value level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
     173            ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, tset, level);
    143174        }
    144175    }
  • code/branches/unity_build/src/libraries/core/command/Shell.h

    r8522 r8524  
    4949
    5050#include "util/OutputHandler.h"
     51#include "core/Core.h"
    5152#include "core/OrxonoxClass.h"
    5253#include "core/input/InputBuffer.h"
     
    8586        Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole.
    8687    */
    87     class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener
     88    class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener, public DevModeListener
    8889    {
    8990        public:
     
    148149            Shell(const Shell& other);
    149150
     151            // DevModeListener
     152            void devModeChanged(bool value);
     153
    150154            void addToHistory(const std::string& command);
    151155            const std::string& getFromHistory() const;
     
    198202            unsigned int              historyOffset_;       ///< The command history is a circular buffer, this variable defines the current write-offset
    199203            std::vector<std::string>  commandHistory_;      ///< The history of commands that were entered by the user
     204            int                       debugLevel_;          //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
    200205            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
    201206    };
Note: See TracChangeset for help on using the changeset viewer.