Skip to content
Snippets Groups Projects
Commit bd7ed780 authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Read log level from env variable in Configuration manager

parent 9d41905b
No related branches found
No related tags found
Loading
......@@ -31,7 +31,7 @@
#include <string>
#include <boost/cstdint.hpp>
#include "itkLoggerBase.h"
#include "OTBCommonExport.h"
namespace otb
......@@ -84,6 +84,10 @@ public:
*/
static RAMValueType GetMaxRAMHint();
static itk::LoggerBase::PriorityLevelType GetLoggerLevel();
private:
ConfigurationManager(); //purposely not implemented
~ConfigurationManager(); //purposely not implemented
......
......@@ -23,6 +23,8 @@
#include "itksys/SystemTools.hxx"
#include <cstdlib>
#include <algorithm>
#include <string>
namespace otb
{
......@@ -59,6 +61,35 @@ ConfigurationManager::RAMValueType ConfigurationManager::GetMaxRAMHint()
}
return value;
}
#define level_macro(x) \
{ \
std::string target = #x; \
if(std::equal(svalue.begin(),svalue.end(),target.begin(),target.end())) \
level = itk::LoggerBase::x; \
} \
itk::LoggerBase::PriorityLevelType ConfigurationManager::GetLoggerLevel()
{
std::string svalue;
#ifndef NDEBUG
itk::LoggerBase::PriorityLevelType level = itk::LoggerBase::DEBUG;
#else
itk::LoggerBase::PriorityLevelType level = itk::LoggerBase::WARNING;
#endif
if(itksys::SystemTools::GetEnv("OTB_LOGGER_LEVEL",svalue))
{
level_macro(DEBUG);
level_macro(WARNING);
level_macro(INFO);
}
return level;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment