diff --git a/include/openspace/engine/configurationmanager.h b/include/openspace/engine/configurationmanager.h index 8ec3aa167d..3a6e34a47a 100644 --- a/include/openspace/engine/configurationmanager.h +++ b/include/openspace/engine/configurationmanager.h @@ -78,12 +78,16 @@ public: static const std::string KeySettingsScript; /// The key that stores the settings for determining log-related settings static const std::string KeyLogging; + /// The key that stores the directory for Logging + static const std::string PartLogDir; /// The key that stores the desired LogLevel for the whole application /// \sa ghoul::logging::LogManager static const std::string PartLogLevel; /// The key that stores whether the log should be immediately flushed after a n /// \sa ghoul::logging::LogManager static const std::string PartImmediateFlush; + /// The key for prefixing PerformanceMeasurement logfiles + static const std::string PartLogPerformancePrefix; /// The key that stores a subdirectory with a description for additional /// ghoul::logging::Log%s to be created /// \sa LogFactory diff --git a/include/openspace/performance/performancemanager.h b/include/openspace/performance/performancemanager.h index 0a81730837..a12c967f56 100644 --- a/include/openspace/performance/performancemanager.h +++ b/include/openspace/performance/performancemanager.h @@ -59,6 +59,12 @@ public: void storeScenePerformanceMeasurements(const std::vector& sceneNodes); void outputLogs(); + + void logDir(std::string dir); + std::string logDir(); + void prefix(std::string prefix); + std::string prefix(); + void enableLogging(); void disableLogging(); void toggleLogging(); @@ -69,6 +75,9 @@ public: private: bool _doPerformanceMeasurements; bool _loggingEnabled; + + std::string _logDir; + std::string _prefix; std::map individualPerformanceLocations; diff --git a/src/engine/configurationmanager.cpp b/src/engine/configurationmanager.cpp index 17bb3e8afd..3800d83f8a 100644 --- a/src/engine/configurationmanager.cpp +++ b/src/engine/configurationmanager.cpp @@ -62,8 +62,11 @@ const string ConfigurationManager::KeyConfigScene = "Scene"; const string ConfigurationManager::KeyConfigTask = "Task"; const string ConfigurationManager::KeyLogging = "Logging"; +const string ConfigurationManager::PartLogDir = "LogDir"; const string ConfigurationManager::PartLogLevel = "LogLevel"; const string ConfigurationManager::PartImmediateFlush = "ImmediateFlush"; +const string ConfigurationManager::PartLogPerformancePrefix = "PerformancePrefix"; + const string ConfigurationManager::PartLogs = "Logs"; const string ConfigurationManager::PartAppend = "Append"; const string ConfigurationManager::PartCapabilitiesVerbosity = "CapabilitiesVerbosity"; diff --git a/src/engine/configurationmanager_doc.inl b/src/engine/configurationmanager_doc.inl index e955c50c75..cda32562bf 100644 --- a/src/engine/configurationmanager_doc.inl +++ b/src/engine/configurationmanager_doc.inl @@ -86,6 +86,18 @@ documentation::Documentation ConfigurationManager::Documentation() { { ConfigurationManager::KeyLogging, new TableVerifier({ + { + ConfigurationManager::PartLogDir, + new StringVerifier, + "The directory for logs", + Optional::Yes + }, + { + ConfigurationManager::PartLogPerformancePrefix, + new StringVerifier, + "A string to prefix PerformanceMeasurement logfiles", + Optional::Yes + }, { ConfigurationManager::PartLogLevel, new StringInListVerifier( diff --git a/src/performance/performancemanager.cpp b/src/performance/performancemanager.cpp index 9fa1b48c25..f8e761aaa5 100644 --- a/src/performance/performancemanager.cpp +++ b/src/performance/performancemanager.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -132,6 +133,8 @@ PerformanceManager::PerformanceManager() : _performanceMemory(nullptr) , _tick(0) , _loggingEnabled(false) + , _logDir(absPath("${BASE_PATH}")) + , _prefix("PM-") { using ghoul::SharedMemory; PerformanceManager::createGlobalSharedMemory(); @@ -207,14 +210,31 @@ void PerformanceManager::outputLogs() { PerformanceLayout* layout = performanceData(); for (size_t i = 0; i < layout->nFunctionEntries; ++i) { - LINFO("Log:" << i << " Node: " << layout->sceneGraphEntries[i].name << " " << layout->functionEntries[i].time[0]); + LINFO("LogA:" << i << " Node: " << layout->sceneGraphEntries[i].name << " " << layout->functionEntries[i].time[0]); } + LINFO("Log Dir: " << absPath(_logDir + "/" + _prefix)); for (size_t i = 0; i < layout->nScaleGraphEntries; ++i) { - LINFO("Log:" << i << " Node: " << layout->sceneGraphEntries[i].name << " " << layout->sceneGraphEntries[i].renderTime[0];); + LINFO("LogB:" << i << " Node: " << layout->sceneGraphEntries[i].name << " " << layout->sceneGraphEntries[i].renderTime[0];); } } +void PerformanceManager::logDir(std::string dir) { + _logDir = absPath(dir); +} + +std::string PerformanceManager::logDir() { + return _logDir; +} + +void PerformanceManager::prefix(std::string prefix) { + _prefix = prefix; +} + +std::string PerformanceManager::prefix() { + return _prefix; +} + void PerformanceManager::enableLogging() { setLogging(true); } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 51daf34c9d..65314e2d71 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -134,6 +134,14 @@ RenderEngine::RenderEngine() if (_performanceMeasurements) { if (!_performanceManager) { _performanceManager = std::make_unique(); + const std::string KeyLogDir = ConfigurationManager::KeyLogging + "." + ConfigurationManager::PartLogDir; + const std::string KeyPrefix = ConfigurationManager::KeyLogging + "." + ConfigurationManager::PartLogPerformancePrefix; + if (OsEng.configurationManager().hasKeyAndValue(KeyLogDir)) { + _performanceManager->logDir(OsEng.configurationManager().value(KeyLogDir)); + } + if (OsEng.configurationManager().hasKeyAndValue(KeyPrefix)) { + _performanceManager->prefix(OsEng.configurationManager().value(KeyPrefix)); + } } } else {