diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index 7325a9adcdfdcab7231522e77b5f184a183c7e79..5a70bff64118fadc0b31514d91bdfbf2de956c36 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -45,13 +45,12 @@ public: itkTypeMacro(Logger, itk::Logger); static Pointer Instance(); - + itkNewMacro(Self); // Overwrite this to provide custom formatting of log entries virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; protected: - itkNewMacro(Self); Logger(); virtual ~Logger() ITK_OVERRIDE; diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index 98b099ac5727190b1492bed00ce1a1d6c39243a8..0ed6b6f790631822e5c26a9afd3214f572897b3d 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -21,6 +21,8 @@ #include "otbLogger.h" #include "itksys/SystemTools.hxx" #include "otbConfigurationManager.h" +#include "itkStdStreamLogOutput.h" +#include <iostream> namespace otb { @@ -30,8 +32,16 @@ Logger::Pointer Logger::Singleton = ITK_NULLPTR; Logger::Pointer Logger::Instance() { if(!Logger::Singleton) + { Logger::Singleton = Logger::New(); + // By default, redirect logs to std::cout + itk::StdStreamLogOutput::Pointer defaultOutput = itk::StdStreamLogOutput::New(); + defaultOutput->SetStream(std::cout); + + Logger::Singleton->AddLogOutput(defaultOutput); + } + return Logger::Singleton; }