Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 23, 2011, 12:45:53 AM (13 years ago)
Author:
landauf
Message:

merged output branch back to trunk.

Changes:

  • you have to include util/Output.h instead of util/Debug.h
  • COUT(x) is now called orxout(level)
  • output levels are now defined by an enum instead of numbers. see util/Output.h for the definition
  • it's possible to use output contexts with orxout(level, context). see util/Output.h for some common contexts. you can define more contexts
  • you must use 'endl' at the end of an output message, '\n' does not flush the message

Output levels:

  • instead of COUT(0) use orxout()
  • instead of COUT(1) use orxout(user_error) or orxout(internal_error)
  • instead of COUT(2) use orxout(user_warning) or orxout(internal_warning)
  • instead of COUT(3) use orxout(user_status/user_info) or orxout(internal_status/internal_info)
  • instead of COUT(4) use orxout(verbose)
  • instead of COUT(5) use orxout(verbose_more)
  • instead of COUT(6) use orxout(verbose_ultra)

Guidelines:

  • user_* levels are for the user, visible in the console and the log-file
  • internal_* levels are for developers, visible in the log-file
  • verbose_* levels are for debugging, only visible if the context of the output is activated

Usage in C++:

  • orxout() << "message" << endl;
  • orxout(level) << "message" << endl;
  • orxout(level, context) << "message" << endl;

Usage in Lua:

  • orxout("message")
  • orxout(orxonox.level.levelname, "message")
  • orxout(orxonox.level.levelname, "context", "message")

Usage in Tcl (and in the in-game-console):

  • orxout levelname message
  • orxout_context levelname context message
  • shortcuts: log message, error message, warning message, status message, info message, debug message
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/GUIManager.cc

    r8729 r8858  
    7373#include "util/Clock.h"
    7474#include "util/Convert.h"
    75 #include "util/Debug.h"
     75#include "util/Output.h"
    7676#include "util/Exception.h"
    7777#include "util/Math.h"
    7878#include "util/OrxAssert.h"
     79#include "util/output/BaseWriter.h"
    7980#include "ConfigValueIncludes.h"
    8081#include "Core.h"
     
    101102        void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard)
    102103        {
    103             int orxonoxLevel = CEGUI::Standard;
     104            OutputLevel orxonoxLevel = level::debug_output;
    104105            switch (level)
    105106            {
    106                 case CEGUI::Errors:      orxonoxLevel = 1; break;
    107                 case CEGUI::Warnings:    orxonoxLevel = 2; break;
    108                 case CEGUI::Standard:    orxonoxLevel = 4; break;
    109                 case CEGUI::Informative: orxonoxLevel = 5; break;
    110                 case CEGUI::Insane:      orxonoxLevel = 6; break;
     107                case CEGUI::Errors:      orxonoxLevel = level::internal_error; break;
     108                case CEGUI::Warnings:    orxonoxLevel = level::internal_warning; break;
     109                case CEGUI::Standard:    orxonoxLevel = level::verbose; break;
     110                case CEGUI::Informative: orxonoxLevel = level::verbose_more; break;
     111                case CEGUI::Insane:      orxonoxLevel = level::verbose_ultra; break;
    111112                default: OrxAssert(false, "CEGUI log level out of range, inspect immediately!");
    112113            }
    113             OutputHandler::getOutStream(orxonoxLevel)
    114                 << "CEGUI: " << message << std::endl;
     114
     115            orxout(orxonoxLevel, context::cegui) << message << endl;
    115116
    116117            CEGUI::DefaultLogger::logEvent(message, level);
     
    256257    {
    257258        RegisterRootObject(GUIManager);
     259
     260        orxout(internal_status) << "initializing GUIManager..." << endl;
     261
    258262        this->setConfigValues();
    259263
    260264        using namespace CEGUI;
    261265
    262         COUT(3) << "Initialising CEGUI." << std::endl;
     266        orxout(internal_info) << "Initialising CEGUI." << endl;
    263267
    264268        this->oldCEGUI_ = false;
    265        
     269
    266270        // Note: No SceneManager specified yet
    267271#ifdef ORXONOX_OLD_CEGUI
     
    300304        std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger());
    301305        ceguiLogger->setLogFilename(PathConfig::getLogPathString() + "cegui.log");
    302         // Set the log level according to ours (translate by subtracting 1)
    303         ceguiLogger->setLoggingLevel(
    304             static_cast<LoggingLevel>(OutputHandler::getInstance().getSoftDebugLevel("logFile") - 1));
     306        ceguiLogger->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_));
    305307        this->ceguiLogger_ = ceguiLogger.release();
    306308
     
    336338        // Set up the sheet manager in the Lua framework
    337339        this->luaState_->doFile("SheetManager.lua");
     340
     341        orxout(internal_status) << "finished initializing GUIManager" << endl;
    338342    }
    339343
    340344    void GUIManager::destroy()
    341345    {
     346        orxout(internal_status) << "destroying GUIManager..." << endl;
     347
    342348        using namespace CEGUI;
    343349
     
    356362#endif
    357363        safeObjectDelete(&luaState_);
     364
     365        orxout(internal_status) << "finished destroying GUIManager" << endl;
    358366    }
    359367
    360368    void GUIManager::setConfigValues(void)
    361369    {
    362         SetConfigValue(guiScheme_, GUIManager::defaultScheme_) .description("Changes the current GUI scheme.") .callback(this, &GUIManager::changedGUIScheme);
     370        SetConfigValue(guiScheme_, GUIManager::defaultScheme_).description("Changes the current GUI scheme.").callback(this, &GUIManager::changedGUIScheme);
    363371        SetConfigValue(numScrollLines_, 1).description("How many lines to scroll in a list if the scroll wheel is used");
     372        SetConfigValueExternal(outputLevelCeguiLog_, BaseWriter::getConfigurableSectionName(), "outputLevelCeguiLog", CEGUI::Standard).description("The log level of the CEGUI log file").callback(this, &GUIManager::changedCeguiOutputLevel);
    364373    }
    365374
    366375    void GUIManager::changedGUIScheme(void)
    367376    {
     377    }
     378
     379    void GUIManager::changedCeguiOutputLevel()
     380    {
     381        if (this->ceguiLogger_)
     382            this->ceguiLogger_->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_));
    368383    }
    369384
     
    670685        {
    671686            // Display the error and proceed. See @remarks why this can be dangerous.
    672             COUT(1) << ex.getMessage() << std::endl;
     687            orxout(internal_error) << ex.getMessage() << endl;
    673688            return true;
    674689        }
Note: See TracChangeset for help on using the changeset viewer.