Changeset 8858 for code/trunk/src/libraries/core/Core.cc
- Timestamp:
- Aug 23, 2011, 12:45:53 AM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore
-
old new 1 1 build 2 2 codeblocks 3 vs 3 4 dependencies
-
- Property svn:mergeinfo changed
/code/branches/output (added) merged: 8739-8740,8765,8771-8772,8774-8780,8787-8789,8794-8799,8801,8803-8812,8814,8816-8817,8820,8822,8825-8837,8840,8844,8846,8848-8850,8853-8854
- Property svn:ignore
-
code/trunk/src/libraries/core/Core.cc
r8729 r8858 52 52 53 53 #include "util/Clock.h" 54 #include "util/ Debug.h"54 #include "util/Output.h" 55 55 #include "util/Exception.h" 56 #include "util/output/LogWriter.h" 56 57 #include "util/Scope.h" 57 58 #include "util/ScopedSingletonManager.h" … … 111 112 , destructionHelper_(this) 112 113 { 114 orxout(internal_status) << "initializing Core object..." << endl; 115 113 116 // Set the hard coded fixed paths 114 117 this->pathConfig_ = new PathConfig(); … … 118 121 119 122 // Load modules 123 orxout(internal_info) << "Loading modules:" << endl; 120 124 const std::vector<std::string>& modulePaths = this->pathConfig_->getModulePaths(); 121 125 for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it) … … 127 131 catch (...) 128 132 { 129 COUT(1) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << std::endl;133 orxout(user_error) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << endl; 130 134 } 131 135 } … … 136 140 // Set configurable paths like log, config and media 137 141 this->pathConfig_->setConfigurablePaths(); 142 143 orxout(internal_info) << "Root path: " << PathConfig::getRootPathString() << endl; 144 orxout(internal_info) << "Executable path: " << PathConfig::getExecutablePathString() << endl; 145 orxout(internal_info) << "Data path: " << PathConfig::getDataPathString() << endl; 146 orxout(internal_info) << "Ext. data path: " << PathConfig::getExternalDataPathString() << endl; 147 orxout(internal_info) << "Config path: " << PathConfig::getConfigPathString() << endl; 148 orxout(internal_info) << "Log path: " << PathConfig::getLogPathString() << endl; 149 orxout(internal_info) << "Modules path: " << PathConfig::getModulePathString() << endl; 138 150 139 151 // create a signal handler (only active for Linux) … … 141 153 this->signalHandler_ = new SignalHandler(); 142 154 this->signalHandler_->doCatch(PathConfig::getExecutablePathString(), PathConfig::getLogPathString() + "orxonox_crash.log"); 143 144 // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% (Windows) was used145 OutputHandler::getInstance().setLogPath(PathConfig::getLogPathString());146 155 147 156 #ifdef ORXONOX_PLATFORM_WINDOWS … … 155 164 156 165 // Manage ini files and set the default settings file (usually orxonox.ini) 166 orxout(internal_info) << "Loading config:" << endl; 157 167 this->configFileManager_ = new ConfigFileManager(); 158 168 this->configFileManager_->setFilename(ConfigFileType::Settings, … … 160 170 161 171 // Required as well for the config values 172 orxout(internal_info) << "Loading language:" << endl; 162 173 this->languageInstance_ = new Language(); 163 174 … … 165 176 // possibility to configure everything below here 166 177 RegisterRootObject(Core); 178 orxout(internal_info) << "configuring Core" << endl; 167 179 this->setConfigValues(); 168 // Rewrite the log file with the correct log levels 169 OutputHandler::getInstance().rewriteLogFile(); 180 181 // Set the correct log path and rewrite the log file with the correct log levels 182 LogWriter::getInstance().setLogPath(PathConfig::getLogPathString()); 170 183 171 184 #if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN) … … 176 189 } 177 190 if (this->bStartIOConsole_) 191 { 192 orxout(internal_info) << "creating IO console" << endl; 178 193 this->ioConsole_ = new IOConsole(); 194 } 179 195 #endif 180 196 181 197 // creates the class hierarchy for all classes with factories 198 orxout(internal_info) << "creating class hierarchy" << endl; 182 199 Identifier::createClassHierarchy(); 183 200 184 201 // Load OGRE excluding the renderer and the render window 202 orxout(internal_info) << "creating GraphicsManager:" << endl; 185 203 this->graphicsManager_ = new GraphicsManager(false); 186 204 … … 190 208 191 209 // Create singletons that always exist (in other libraries) 210 orxout(internal_info) << "creating root scope:" << endl; 192 211 this->rootScope_ = new Scope<ScopeID::Root>(); 193 212 … … 204 223 } 205 224 else 206 COUT(0) << "Error: Could not open file for documentation writing" << endl; 207 } 225 orxout(internal_error) << "Could not open file for documentation writing" << endl; 226 } 227 228 orxout(internal_status) << "finished initializing Core object" << endl; 208 229 } 209 230 210 231 void Core::destroy() 211 232 { 233 orxout(internal_status) << "destroying Core object..." << endl; 234 212 235 // Remove us from the object lists again to avoid problems when destroying them 213 236 this->unregisterObject(); … … 228 251 safeObjectDelete(&dynLibManager_); 229 252 safeObjectDelete(&pathConfig_); 230 } 231 232 namespace DefaultLevelLogFile 233 { 234 const OutputLevel::Value Dev = OutputLevel::Debug; 235 const OutputLevel::Value User = OutputLevel::Info; 253 254 orxout(internal_status) << "finished destroying Core object" << endl; 236 255 } 237 256 … … 239 258 void Core::setConfigValues() 240 259 { 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) 245 .description("The maximum level of debug output written to the log file"); 246 OutputHandler::getInstance().setSoftDebugLevel("LogFile", debugLevelLogFile_); 260 SetConfigValueExternal(LogWriter::getInstance().configurableMaxLevel_, 261 LogWriter::getInstance().getConfigurableSectionName(), 262 LogWriter::getInstance().getConfigurableMaxLevelName(), 263 LogWriter::getInstance().configurableMaxLevel_) 264 .description("The maximum level of output shown in the log file") 265 .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableLevel); 266 SetConfigValueExternal(LogWriter::getInstance().configurableAdditionalContextsMaxLevel_, 267 LogWriter::getInstance().getConfigurableSectionName(), 268 LogWriter::getInstance().getConfigurableAdditionalContextsMaxLevelName(), 269 LogWriter::getInstance().configurableAdditionalContextsMaxLevel_) 270 .description("The maximum level of output shown in the log file for additional contexts") 271 .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableAdditionalContextsLevel); 272 SetConfigValueExternal(LogWriter::getInstance().configurableAdditionalContexts_, 273 LogWriter::getInstance().getConfigurableSectionName(), 274 LogWriter::getInstance().getConfigurableAdditionalContextsName(), 275 LogWriter::getInstance().configurableAdditionalContexts_) 276 .description("Additional output contexts shown in the log file") 277 .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableAdditionalContexts); 247 278 248 279 SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun()) … … 279 310 void Core::devModeChanged() 280 311 { 281 bool isNormal = (bDevMode_ == PathConfig::buildDirectoryRun());282 if (isNormal)283 {284 ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", update);285 }286 else287 {288 OutputLevel::Value level = (bDevMode_ ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);289 ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", tset, level);290 }291 292 312 // Inform listeners 293 313 ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin(); … … 316 336 void Core::loadGraphics() 317 337 { 338 orxout(internal_info) << "loading graphics in Core" << endl; 339 318 340 // Any exception should trigger this, even in upgradeToGraphics (see its remarks) 319 341 Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics); … … 327 349 { 328 350 // Exit the application if the Ogre config dialog was canceled 329 COUT(1) << Exception::handleMessage() << std::endl;351 orxout(user_error) << Exception::handleMessage() << endl; 330 352 exit(EXIT_FAILURE); 331 353 } … … 338 360 // and reloaded between throw and catch (access violation in MSVC). 339 361 // That's why we abort completely and only display the exception. 340 COUT(1) << "An exception occurred during upgrade to graphics. "341 << "That is unrecoverable. The message was:" << endl342 << Exception::handleMessage() << endl;362 orxout(user_error) << "An exception occurred during upgrade to graphics. " 363 << "That is unrecoverable. The message was:" << endl 364 << Exception::handleMessage() << endl; 343 365 abort(); 344 366 } … … 357 379 358 380 // Create singletons associated with graphics (in other libraries) 381 orxout(internal_info) << "creating graphics scope:" << endl; 359 382 graphicsScope_ = new Scope<ScopeID::Graphics>(); 360 383 361 384 unloader.Dismiss(); 385 386 orxout(internal_info) << "finished loading graphics in Core" << endl; 362 387 } 363 388 364 389 void Core::unloadGraphics() 365 390 { 391 orxout(internal_info) << "unloading graphics in Core" << endl; 392 366 393 safeObjectDelete(&graphicsScope_); 367 394 safeObjectDelete(&guiManager_); … … 374 401 catch (...) 375 402 { 376 COUT(0) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << std::endl377 << "Another exception might be being handled which may lead to undefined behaviour!" << std::endl378 << "Terminating the program." << std::endl;403 orxout(user_error) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << endl 404 << "Another exception might be being handled which may lead to undefined behaviour!" << endl 405 << "Terminating the program." << endl; 379 406 abort(); 380 407 }
Note: See TracChangeset
for help on using the changeset viewer.