Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 27, 2009, 2:47:14 PM (15 years ago)
Author:
rgrieder
Message:

Changed Output concept a little bit to allow for more general use.
Every output (log) target has to be implemented as OutputListener. There is already a LogFileWriter and a MemoryLogWriter (stores ALL the log in a vector and provides iterators).
The OutputListener has a unique and constant name, a stream pointer and a soft debug level (that can only be changed via OutputHandler::setSoftDebugLevel(name, level)).
This concept doesn't require the OutputBuffer anymore, so I deleted it.

The adjustments in the Shell are just preliminary for this commit.

File:
1 edited

Legend:

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

    r5992 r5994  
    106106        void setConfigValues()
    107107        {
    108 #ifdef NDEBUG
    109             const unsigned int defaultLevelConsole = 1;
    110             const unsigned int defaultLevelLogfile = 3;
    111             const unsigned int defaultLevelShell   = 1;
     108#ifdef ORXONOX_RELEASE
     109            const unsigned int defaultLevelLogFile = 3;
    112110#else
    113             const unsigned int defaultLevelConsole = 3;
    114             const unsigned int defaultLevelLogfile = 4;
    115             const unsigned int defaultLevelShell   = 3;
    116 #endif
    117             SetConfigValue(softDebugLevelConsole_, defaultLevelConsole)
    118                 .description("The maximal level of debug output shown in the console")
    119                 .callback(this, &CoreConfiguration::debugLevelChanged);
    120             SetConfigValue(softDebugLevelLogfile_, defaultLevelLogfile)
    121                 .description("The maximal level of debug output shown in the logfile")
    122                 .callback(this, &CoreConfiguration::debugLevelChanged);
    123             SetConfigValue(softDebugLevelShell_, defaultLevelShell)
    124                 .description("The maximal level of debug output shown in the ingame shell")
    125                 .callback(this, &CoreConfiguration::debugLevelChanged);
     111            const unsigned int defaultLevelLogFile = 4;
     112#endif
     113            SetConfigValueGeneric(ConfigFileType::Settings, softDebugLevelLogFile_, "softDebugLevelLogFile", "OutputHandler", defaultLevelLogFile)
     114                .description("The maximum level of debug output shown in the log file");
     115            OutputHandler::getInstance().setSoftDebugLevel(OutputHandler::logFileOutputListenerName_s, this->softDebugLevelLogFile_);
    126116
    127117            SetConfigValue(language_, Language::getInstance().defaultLanguage_)
     
    131121                .description("If true, all random actions are different each time you start the game")
    132122                .callback(this, &CoreConfiguration::initializeRandomNumberGenerator);
    133         }
    134 
    135         /**
    136             @brief Callback function if the debug level has changed.
    137         */
    138         void debugLevelChanged()
    139         {
    140             // softDebugLevel_ is the maximum of the 3 variables
    141             this->softDebugLevel_ = this->softDebugLevelConsole_;
    142             if (this->softDebugLevelLogfile_ > this->softDebugLevel_)
    143                 this->softDebugLevel_ = this->softDebugLevelLogfile_;
    144             if (this->softDebugLevelShell_ > this->softDebugLevel_)
    145                 this->softDebugLevel_ = this->softDebugLevelShell_;
    146 
    147             OutputHandler::setSoftDebugLevel(OutputHandler::LD_All,     this->softDebugLevel_);
    148             OutputHandler::setSoftDebugLevel(OutputHandler::LD_Console, this->softDebugLevelConsole_);
    149             OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
    150             OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell,   this->softDebugLevelShell_);
    151123        }
    152124
     
    179151        }
    180152
    181         int softDebugLevel_;                            //!< The debug level
    182         int softDebugLevelConsole_;                     //!< The debug level for the console
    183         int softDebugLevelLogfile_;                     //!< The debug level for the logfile
    184         int softDebugLevelShell_;                       //!< The debug level for the ingame shell
     153        int softDebugLevelLogFile_;                     //!< The debug level for the log file (belongs to OutputHandler)
    185154        std::string language_;                          //!< The language
    186155        bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
     
    228197
    229198        // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% (Windows) was used
    230         OutputHandler::getOutStream().setLogPath(PathConfig::getLogPathString());
     199        OutputHandler::getInstance().setLogPath(PathConfig::getLogPathString());
    231200
    232201        // Parse additional options file now that we know its path
     
    328297        bGraphicsLoaded_ = false;
    329298        GameMode::bShowsGraphics_s = false;
    330     }
    331 
    332     /**
    333         @brief Returns the softDebugLevel for the given device (returns a default-value if the class is right about to be created).
    334         @param device The device
    335         @return The softDebugLevel
    336     */
    337     /*static*/ int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
    338     {
    339         switch (device)
    340         {
    341         case OutputHandler::LD_All:
    342             return Core::getInstance().configuration_->softDebugLevel_;
    343         case OutputHandler::LD_Console:
    344             return Core::getInstance().configuration_->softDebugLevelConsole_;
    345         case OutputHandler::LD_Logfile:
    346             return Core::getInstance().configuration_->softDebugLevelLogfile_;
    347         case OutputHandler::LD_Shell:
    348             return Core::getInstance().configuration_->softDebugLevelShell_;
    349         default:
    350             assert(0);
    351             return 2;
    352         }
    353     }
    354 
    355      /**
    356         @brief Sets the softDebugLevel for the given device. Please use this only temporary and restore the value afterwards, as it overrides the configured value.
    357         @param device The device
    358         @param level The level
    359     */
    360     /*static*/ void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
    361     {
    362         if (device == OutputHandler::LD_All)
    363             Core::getInstance().configuration_->softDebugLevel_ = level;
    364         else if (device == OutputHandler::LD_Console)
    365             Core::getInstance().configuration_->softDebugLevelConsole_ = level;
    366         else if (device == OutputHandler::LD_Logfile)
    367             Core::getInstance().configuration_->softDebugLevelLogfile_ = level;
    368         else if (device == OutputHandler::LD_Shell)
    369             Core::getInstance().configuration_->softDebugLevelShell_ = level;
    370 
    371         OutputHandler::setSoftDebugLevel(device, level);
    372299    }
    373300
Note: See TracChangeset for help on using the changeset viewer.