diff --git a/Modules/Core/Common/include/otbConfigurationManager.h b/Modules/Core/Common/include/otbConfigurationManager.h index 7b32b3dc729e0ae5bd974ac6f6786ce0e8d4493d..30e3d112208a677f8568585ca11695cdc8506082 100644 --- a/Modules/Core/Common/include/otbConfigurationManager.h +++ b/Modules/Core/Common/include/otbConfigurationManager.h @@ -93,7 +93,7 @@ public: * INFO, WARNING, CRITICAL or FATAL, the logger level will be * set accordingly. * - * Priority is DEBUG < INFO < WARNING < CRITICAL < FATAL. + * Priority is DEBUG < INFO < WARNING < CRITICAL < FATAL. * * Only messages with a higher priority than the logger level will * be displayed. diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index 21aff6e14beaa2f38d108d18db58b9b310d7fdc8..d61c22bf4afd22fa0c560fc7725bbfed5f90ecf5 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -49,7 +49,7 @@ public: itkNewMacro(Self); // Overwrite this to provide custom formatting of log entries - virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; + std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; void LogSetupInformation(); diff --git a/Modules/Core/Common/include/otbMacro.h b/Modules/Core/Common/include/otbMacro.h index 5dcca1bab9cb0755aa4f22f13e0560b7fa30782a..6a248d4551a2f3f57220b4de62f3550a7dee5ad0 100644 --- a/Modules/Core/Common/include/otbMacro.h +++ b/Modules/Core/Common/include/otbMacro.h @@ -50,6 +50,7 @@ namespace otb #define otbClassContext(x) \ << this->GetNameOfClass() << " (" << this << "): " x +// Beware that to log to CRITICAL level, level should be passed as "Error" #define otbLogMacro(level,msg) \ { \ std::ostringstream itkmsg; \ @@ -58,21 +59,14 @@ namespace otb } +// Re-definition of old log macros to use the otbLogMacro #define otbDebugMacro(x) otbLogMacro(Debug,otbFileContext(otbClassContext(x))) #define otbMsgDebugMacro(x) otbLogMacro(Debug,otbFileContext(x)) #define otbGenericMsgDebugMacro(x) otbLogMacro(Debug,x) #define otbMsgDevMacro(x) otbLogMacro(Debug,otbFileContext(x)) #define otbWarningMacro(x) otbLogMacro(Warning,otbFileContext(otbClassContext(x))) #define otbGenericWarningMacro(x) otbLogMacro(Warning,otbFileContext(x)) - - - -// TODO: Address this macro as well -#define otbGenericMsgTestingMacro(x) \ - { \ - std::cout x << std::endl; \ - } - +#define otbGenericMsgTestingMAcro(x) otbLogMacro(Info,"[testing] "<<x) /** This macro is used to control condition. It use ONLY by the OTB developers * diff --git a/Modules/Core/Common/src/otbConfigurationManager.cxx b/Modules/Core/Common/src/otbConfigurationManager.cxx index 4b5875b3c5fb094e6a6c48023d058b295a188193..48108116bf6a1cd40c661b4e2050eea8ecdf3a3b 100644 --- a/Modules/Core/Common/src/otbConfigurationManager.cxx +++ b/Modules/Core/Common/src/otbConfigurationManager.cxx @@ -20,6 +20,8 @@ #include "otbConfigurationManager.h" +#include "otbMacro.h" + #include "itksys/SystemTools.hxx" #include <cstdlib> @@ -85,11 +87,26 @@ itk::LoggerBase::PriorityLevelType ConfigurationManager::GetLoggerLevel() if(itksys::SystemTools::GetEnv("OTB_LOGGER_LEVEL",svalue)) { - level_macro(DEBUG); - level_macro(WARNING); - level_macro(INFO); - level_macro(CRITICAL); - level_macro(FATAL); + if(svalue.compare("DEBUG") == 0) + { + level = itk::LoggerBase::DEBUG; + } + else if(svalue.compare("INFO") == 0) + { + level = itk::LoggerBase::INFO; + } + else if(svalue.compare("WARNING") == 0) + { + level = itk::LoggerBase::WARNING; + } + else if(svalue.compare("CRITICAL") == 0) + { + level = itk::LoggerBase::CRITICAL; + } + else + { + otbLogMacro(Error,<<"Unknown value for OTB_LOGGER_LEVEL_MACRO. Possible values are DEBUG, INFO, WARNING, CRITICAL."); + } } return level; } diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index e03253aa94c20c0ca4c18dbec1d3e63a66d4957b..37a2ef05404e5ae0622beae3e1686c3189679ae4 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -71,14 +71,17 @@ void Logger::LogSetupInformation() oss<<"Default RAM limit for OTB is "<<otb::ConfigurationManager::GetMaxRAMHint()<<" MB"<<std::endl; this->Info(oss.str()); oss.str(""); + oss.clear(); - oss<<"Gdal maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" MB"<<std::endl; + oss<<"GDAL maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" MB"<<std::endl; this->Info(oss.str()); oss.str(""); + oss.clear(); oss<<"OTB will use at most "<<itk::MultiThreader::GetGlobalDefaultNumberOfThreads()<<" threads"<<std::endl; this->Info(oss.str()); oss.str(""); + oss.clear(); } std::string Logger::BuildFormattedEntry(itk::Logger::PriorityLevelType level, std::string const & content) diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index 944bbf51f9e974ff8f80ea376b5747b0144a3049..ee8f3b62972942a8cbb82551c2fc74c9f6141137 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -860,7 +860,7 @@ void GDALImageIO::InternalReadImageInformation() } else { - otbLogMacro(Warning,<< "Geotransform reported by Gdal is invalid (spacing = 0)"); + otbLogMacro(Warning,<< "Geotransform reported by GDAL is invalid (spacing = 0)"); m_Spacing[0] = 1; m_Spacing[1] = 1; } diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 4cc2c316da44a0a767217d92968b937f5c808c49..907da0d9bd562a6954e2978a34a38830f671de09 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -513,7 +513,7 @@ ImageFileWriter<TInputImage> /** Control if the ImageIO is CanStreamWrite */ if (m_ImageIO->CanStreamWrite() == false) { - otbLogMacro(Warning,<<"The file format of " << m_FileName.c_str() << + otbLogMacro(Warning,<<"The file format of " << m_FileName << " does not support streaming. All data will be loaded to memory"); this->SetNumberOfDivisionsStrippedStreaming(1); }