From f703e27af548e790991672c5f9d13b6b80717ba7 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 6 Mar 2018 14:58:00 +0100 Subject: [PATCH] ENH: Revert changes on ApplicationEngine, keep its logging as is --- .../include/otbWrapperApplication.h | 5 +++++ .../src/otbWrapperApplication.cxx | 22 ++++++++++++++++--- .../src/otbWrapperCompositeApplication.cxx | 2 ++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 76ccd9bb5f..c6317be142 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -101,6 +101,7 @@ public: m_Name = name; GetDocExample()->SetApplicationName(name); this->Modified(); + m_Logger->SetName(name); } itkGetStringMacro(Name); @@ -708,6 +709,9 @@ public: otb::Logger* GetLogger() const; + /** Sets the logger instance of the application (use with caution) */ + void SetLogger(otb::Logger *logger); + itk::ProcessObject* GetProgressSource() const; std::string GetProgressDescription() const; @@ -980,6 +984,7 @@ private: std::string m_Name; std::string m_Description; ParameterGroup::Pointer m_ParameterList; + otb::Logger::Pointer m_Logger; itk::ProcessObject::Pointer m_ProgressSource; std::string m_ProgressSourceDescription; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cc0790f406..cca32d50d3 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -46,7 +46,6 @@ #include <exception> #include "itkMacro.h" - namespace otb { namespace Wrapper @@ -55,6 +54,7 @@ namespace Wrapper Application::Application() : m_Name(""), m_Description(""), + m_Logger(otb::Logger::New()), m_ProgressSourceDescription(""), m_DocName(""), m_DocLongDescription(""), @@ -66,7 +66,10 @@ Application::Application() m_HaveInXML(true), m_HaveOutXML(true), m_IsInXMLParsed(false) -{} +{ + // Don't call Init from the constructor, since it calls a virtual method ! + m_Logger->SetName("Application.logger"); +} Application::~Application() { @@ -74,7 +77,15 @@ Application::~Application() otb::Logger* Application::GetLogger() const { - return otb::Logger::Instance(); + return m_Logger; +} + +void Application::SetLogger(otb::Logger *logger) +{ + if (m_Logger != logger) + { + m_Logger = logger; + } } std::vector<std::string> @@ -1656,6 +1667,11 @@ Application::IsParameterMissing(const std::string &key) const } level++; } + if (ret) + { + // the missing parameter is on an active branch : we need it + otbDebugMacro("MISSING : "<< key << " (Level "<< split.size()<<")"); + } } return ret; } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx index 7ebfa4d59a..db216594f5 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx @@ -62,6 +62,8 @@ CompositeApplication InternalApplication container; container.App = ApplicationRegistry::CreateApplication(appType); container.Desc = desc; + // Setup logger + container.App->SetLogger(this->GetLogger()); container.App->AddObserver(AddProcessToWatchEvent(), m_AddProcessCommand.GetPointer()); m_AppContainer[key] = container; return true; -- GitLab