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/GraphicsManager.cc

    r8423 r8858  
    104104        RegisterObject(GraphicsManager);
    105105
     106        orxout(internal_status) << "initializing GraphicsManager..." << endl;
    106107        this->setConfigValues();
    107108
     
    114115        resources_.reset(new XMLFile("DefaultResources.oxr"));
    115116        resources_->setLuaSupport(false);
    116         Loader::open(resources_.get());
     117        Loader::open(resources_.get(), ClassTreeMask(), false);
    117118
    118119        // Only for runs in the build directory (not installed)
     
    122123        extResources_.reset(new XMLFile("resources.oxr"));
    123124        extResources_->setLuaSupport(false);
    124         Loader::open(extResources_.get());
     125        Loader::open(extResources_.get(), ClassTreeMask(), false);
    125126
    126127        if (bLoadRenderer)
     
    129130            this->upgradeToGraphics();
    130131        }
     132
     133        orxout(internal_status) << "finished initializing GraphicsManager" << endl;
    131134    }
    132135
    133136    void GraphicsManager::destroy()
    134137    {
     138        orxout(internal_status) << "destroying GraphicsManager..." << endl;
     139
    135140        Loader::unload(debugOverlay_.get());
    136141
     
    148153        safeObjectDelete(&ogreLogger_);
    149154        safeObjectDelete(&ogreWindowEventListener_);
     155
     156        orxout(internal_status) << "finished destroying GraphicsManager" << endl;
    150157    }
    151158
     
    158165        SetConfigValue(ogreLogFile_,     "ogre.log")
    159166            .description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
    160         SetConfigValue(ogreLogLevelTrivial_ , 5)
    161             .description("Corresponding orxonox debug level for ogre Trivial");
    162         SetConfigValue(ogreLogLevelNormal_  , 4)
    163             .description("Corresponding orxonox debug level for ogre Normal");
    164         SetConfigValue(ogreLogLevelCritical_, 2)
    165             .description("Corresponding orxonox debug level for ogre Critical");
    166167    }
    167168
     
    179180            return;
    180181
     182        orxout(internal_info) << "GraphicsManager upgrade to graphics" << endl;
     183
    181184        // load all the required plugins for Ogre
    182185        this->loadOgrePlugins();
     
    189192        // choose another resource group.
    190193        Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
     194
     195        orxout(internal_info) << "GraphicsManager finished upgrade to graphics" << endl;
    191196    }
    192197
     
    197202    void GraphicsManager::loadOgreRoot()
    198203    {
    199         COUT(3) << "Setting up Ogre..." << std::endl;
     204        orxout(internal_info) << "Setting up Ogre..." << endl;
    200205
    201206        if (ogreConfigFile_.empty())
    202207        {
    203             COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
     208            orxout(internal_warning) << "Ogre config file set to \"\". Defaulting to config.cfg" << endl;
    204209            ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
    205210        }
    206211        if (ogreLogFile_.empty())
    207212        {
    208             COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
     213            orxout(internal_warning) << "Ogre log file set to \"\". Defaulting to ogre.log" << endl;
    209214            ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
    210215        }
     
    216221        // Ogre::Root will detect that we've already created a Log
    217222        ogreLogger_ = new Ogre::LogManager();
    218         COUT(4) << "Ogre LogManager created" << std::endl;
     223        orxout(internal_info) << "Ogre LogManager created" << endl;
    219224
    220225        // create our own log that we can listen to
    221226        Ogre::Log *myLog;
    222227        myLog = ogreLogger_->createLog(ogreLogFilepath.string(), true, false, false);
    223         COUT(4) << "Ogre Log created" << std::endl;
     228        orxout(internal_info) << "Ogre Log created" << endl;
    224229
    225230        myLog->setLogDetail(Ogre::LL_BOREME);
    226231        myLog->addListener(this);
    227232
    228         COUT(4) << "Creating Ogre Root..." << std::endl;
     233        orxout(internal_info) << "Creating Ogre Root..." << endl;
    229234
    230235        // check for config file existence because Ogre displays (caught) exceptions if not
     
    240245        ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.string(), ogreLogFilepath.string());
    241246
    242         COUT(3) << "Ogre set up done." << std::endl;
     247        orxout(internal_info) << "Ogre set up done." << endl;
    243248    }
    244249
    245250    void GraphicsManager::loadOgrePlugins()
    246251    {
     252        orxout(internal_info) << "loading ogre plugins" << endl;
     253
    247254        // Plugin path can have many different locations...
    248255        std::string pluginPath = specialConfig::ogrePluginsDirectory;
     
    277284    void GraphicsManager::loadRenderer()
    278285    {
    279         CCOUT(4) << "Configuring Renderer" << std::endl;
     286        orxout(internal_info) << "GraphicsManager: Configuring Renderer" << endl;
    280287
    281288        bool updatedConfig = Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp();
    282289        if (updatedConfig)
    283             COUT(2) << "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << std::endl;
     290            orxout(user_info)<< "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << endl;
    284291
    285292        if (!ogreRoot_->restoreConfig() || updatedConfig)
     
    291298        }
    292299
    293         CCOUT(4) << "Creating render window" << std::endl;
     300        orxout(internal_info) << "Creating render window" << endl;
    294301
    295302        this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox");
     
    317324    {
    318325        // Load debug overlay to show info about fps and tick time
    319         COUT(4) << "Loading Debug Overlay..." << std::endl;
     326        orxout(internal_info) << "Loading Debug Overlay..." << endl;
    320327        debugOverlay_.reset(new XMLFile("debug.oxo"));
    321         Loader::open(debugOverlay_.get());
     328        Loader::open(debugOverlay_.get(), ClassTreeMask(), false);
    322329    }
    323330
     
    396403        Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
    397404    {
    398         int orxonoxLevel;
     405        OutputLevel orxonoxLevel;
    399406        std::string introduction;
    400407        // Do not show caught OGRE exceptions in front
    401408        if (message.find("EXCEPTION") != std::string::npos)
    402409        {
    403             orxonoxLevel = OutputLevel::Debug;
     410            orxonoxLevel = level::internal_error;
    404411            introduction = "Ogre, caught exception: ";
    405412        }
     
    409416            {
    410417            case Ogre::LML_TRIVIAL:
    411                 orxonoxLevel = this->ogreLogLevelTrivial_;
     418                orxonoxLevel = level::verbose_more;
    412419                break;
    413420            case Ogre::LML_NORMAL:
    414                 orxonoxLevel = this->ogreLogLevelNormal_;
     421                orxonoxLevel = level::verbose;
    415422                break;
    416423            case Ogre::LML_CRITICAL:
    417                 orxonoxLevel = this->ogreLogLevelCritical_;
     424                orxonoxLevel = level::internal_warning;
    418425                break;
    419426            default:
    420                 orxonoxLevel = 0;
     427                orxonoxLevel = level::debug_output;
    421428            }
    422429            introduction = "Ogre: ";
    423430        }
    424         OutputHandler::getOutStream(orxonoxLevel)
    425             << introduction << message << std::endl;
     431
     432        orxout(orxonoxLevel, context::ogre) << introduction << message << endl;
    426433    }
    427434
Note: See TracChangeset for help on using the changeset viewer.