From 28f957d0066407e75944a323ea7aa2770abe8ffc Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 6 Mar 2018 15:54:58 +0100 Subject: [PATCH] ENH: Report useful info at logger startup --- Modules/Core/Common/include/otbLogger.h | 2 ++ Modules/Core/Common/src/CMakeLists.txt | 3 +-- Modules/Core/Common/src/otbLogger.cxx | 23 ++++++++++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index 7325a9adcd..f4814d1fd7 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -50,6 +50,8 @@ public: // Overwrite this to provide custom formatting of log entries virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; + void LogSetupInformation(); + protected: itkNewMacro(Self); Logger(); diff --git a/Modules/Core/Common/src/CMakeLists.txt b/Modules/Core/Common/src/CMakeLists.txt index 50e410e9c8..ce5d20761e 100644 --- a/Modules/Core/Common/src/CMakeLists.txt +++ b/Modules/Core/Common/src/CMakeLists.txt @@ -34,8 +34,7 @@ set(OTBCommon_SRC add_library(OTBCommon ${OTBCommon_SRC}) target_link_libraries(OTBCommon - ${OTBITK_LIBRARIES} - + ${OTBITK_LIBRARIES} ${OTBGDAL_LIBRARIES} ) otb_module_target(OTBCommon) diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index 0ed6b6f790..1dd9303f26 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -23,6 +23,8 @@ #include "otbConfigurationManager.h" #include "itkStdStreamLogOutput.h" #include <iostream> +#include "gdal.h" +#include "itkMultiThreader.h" namespace otb { @@ -40,12 +42,14 @@ Logger::Pointer Logger::Instance() defaultOutput->SetStream(std::cout); Logger::Singleton->AddLogOutput(defaultOutput); + + // Log setup information + Logger::Singleton->LogSetupInformation(); } return Logger::Singleton; } - Logger::Logger() { this->SetPriorityLevel(otb::ConfigurationManager::GetLoggerLevel()); @@ -60,6 +64,23 @@ Logger::~Logger() { } +void Logger::LogSetupInformation() +{ + std::ostringstream oss; + + oss<<"Default RAM limit for OTB is "<<otb::ConfigurationManager::GetMaxRAMHint()<<" Mb"<<std::endl; + this->Info(oss.str()); + oss.str(""); + + oss<<"Gdal maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" Mb"<<std::endl; + this->Info(oss.str()); + oss.str(""); + + oss<<"OTB will use at most "<<itk::MultiThreader::GetGlobalDefaultNumberOfThreads()<<" threads"<<std::endl; + this->Info(oss.str()); + oss.str(""); +} + std::string Logger::BuildFormattedEntry(itk::Logger::PriorityLevelType level, std::string const & content) { static const std::string levelString[] = { "(MUSTFLUSH)", "(FATAL)", "(CRITICAL)", -- GitLab