From c0d97f6345833d9cdac4b7c72235f8e3e6535eb7 Mon Sep 17 00:00:00 2001 From: Julien Malik <julien.malik@c-s.fr> Date: Mon, 19 Sep 2011 16:19:52 +0200 Subject: [PATCH] ENH: add logging to command line launcher --- Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx | 6 ++++++ Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx b/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx index a4038607ca..da90152912 100644 --- a/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx +++ b/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx @@ -52,6 +52,8 @@ CommandLineLauncher::CommandLineLauncher() : m_Expression(""), m_WatcherList() { m_Application = NULL; m_Parser = CommandLineParser::New(); + m_LogOutput = itk::StdStreamLogOutput::New(); + m_LogOutput->SetStream( std::cout ); } CommandLineLauncher::CommandLineLauncher(const char * exp) : m_Expression(exp) @@ -264,6 +266,10 @@ CommandLineLauncher::LoadApplication() std::cerr << "ERROR: Could not find application \"" << moduleName <<"\""<< std::endl; return; } + + // Attach log output to the Application logger + m_Application->GetLogger()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE); + m_Application->GetLogger()->AddLogOutput(m_LogOutput); } CommandLineLauncher::ParamResultType diff --git a/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.h b/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.h index 470daeaa97..0f8ae8b719 100644 --- a/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.h +++ b/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.h @@ -27,6 +27,8 @@ #include "itksys/SystemTools.hxx" #include "otbWrapperCommandLineParser.h" +#include "itkStdStreamLogOutput.h" + #include "otbStandardFilterWatcher.h" @@ -141,6 +143,8 @@ private: WatcherListType m_WatcherList; + itk::StdStreamLogOutput::Pointer m_LogOutput; + }; //end class } // end namespace Wrapper -- GitLab