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

ENH: Make std::cout the default output for library logs

parent f703e27a
No related branches found
No related tags found
1 merge request!20Refactor logging for the whole library
...@@ -45,13 +45,12 @@ public: ...@@ -45,13 +45,12 @@ public:
itkTypeMacro(Logger, itk::Logger); itkTypeMacro(Logger, itk::Logger);
static Pointer Instance(); static Pointer Instance();
itkNewMacro(Self);
// Overwrite this to provide custom formatting of log entries // Overwrite this to provide custom formatting of log entries
virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE;
protected: protected:
itkNewMacro(Self);
Logger(); Logger();
virtual ~Logger() ITK_OVERRIDE; virtual ~Logger() ITK_OVERRIDE;
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "otbLogger.h" #include "otbLogger.h"
#include "itksys/SystemTools.hxx" #include "itksys/SystemTools.hxx"
#include "otbConfigurationManager.h" #include "otbConfigurationManager.h"
#include "itkStdStreamLogOutput.h"
#include <iostream>
namespace otb namespace otb
{ {
...@@ -30,8 +32,16 @@ Logger::Pointer Logger::Singleton = ITK_NULLPTR; ...@@ -30,8 +32,16 @@ Logger::Pointer Logger::Singleton = ITK_NULLPTR;
Logger::Pointer Logger::Instance() Logger::Pointer Logger::Instance()
{ {
if(!Logger::Singleton) if(!Logger::Singleton)
{
Logger::Singleton = Logger::New(); 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; return Logger::Singleton;
} }
......
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