From 88cc0c075521f67963c34726544a37f3aa5d6eab Mon Sep 17 00:00:00 2001
From: Julien Malik <julien.malik@c-s.fr>
Date: Mon, 19 Sep 2011 18:11:02 +0200
Subject: [PATCH] ENH: add macro to ease logging in applications

---
 .../otbWrapperApplication.cxx                 |  2 +-
 .../ApplicationEngine/otbWrapperApplication.h |  2 +
 Code/ApplicationEngine/otbWrapperMacros.h     | 64 +++++++++++++++++++
 3 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 Code/ApplicationEngine/otbWrapperMacros.h

diff --git a/Code/ApplicationEngine/otbWrapperApplication.cxx b/Code/ApplicationEngine/otbWrapperApplication.cxx
index 3604dc62c2..3563cd4ae5 100644
--- a/Code/ApplicationEngine/otbWrapperApplication.cxx
+++ b/Code/ApplicationEngine/otbWrapperApplication.cxx
@@ -52,7 +52,7 @@ Application::Application()
   // Don't call Init from the constructor, since it calls a virtual method !
 
   m_Logger->SetName("Application.logger");
-  m_Logger->SetPriorityLevel(itk::LoggerBase::INFO);
+  m_Logger->SetPriorityLevel(itk::LoggerBase::DEBUG);
   m_Logger->SetLevelForFlushing(itk::LoggerBase::CRITICAL);
 
 }
diff --git a/Code/ApplicationEngine/otbWrapperApplication.h b/Code/ApplicationEngine/otbWrapperApplication.h
index a84146f435..1fd4c9fa65 100644
--- a/Code/ApplicationEngine/otbWrapperApplication.h
+++ b/Code/ApplicationEngine/otbWrapperApplication.h
@@ -25,7 +25,9 @@
 
 #include "otbWrapperTypes.h"
 #include "otbWrapperParameterGroup.h"
+
 #include "itkLogger.h"
+#include "otbWrapperMacros.h"
 
 namespace otb
 {
diff --git a/Code/ApplicationEngine/otbWrapperMacros.h b/Code/ApplicationEngine/otbWrapperMacros.h
new file mode 100644
index 0000000000..cdd3103a36
--- /dev/null
+++ b/Code/ApplicationEngine/otbWrapperMacros.h
@@ -0,0 +1,64 @@
+/*=========================================================================
+
+ Program:   ORFEO Toolbox
+ Language:  C++
+ Date:      $Date$
+ Version:   $Revision$
+
+
+ Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
+ See OTBCopyright.txt for details.
+
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE.  See the above copyright notices for more information.
+
+ =========================================================================*/
+#ifndef __otbWrapperMacros_h
+#define __otbWrapperMacros_h
+
+
+#define otbAppLogFATAL(x) \
+  { \
+  std::ostringstream message; \
+  message << "" x << std::endl; \
+  this->GetLogger()->Write( itk::LoggerBase::FATAL, message.str() ); \
+  }
+
+#define otbAppLogCRITICAL(x) \
+  { \
+  std::ostringstream message; \
+  message << "" x << std::endl; \
+  this->GetLogger()->Write( itk::LoggerBase::CRITICAL, message.str() ); \
+  }
+
+#define otbAppLogERROR(x) \
+  { \
+  std::ostringstream message; \
+  message << "" x << std::endl; \
+  this->GetLogger()->Write( itk::LoggerBase::ERROR, message.str() ); \
+  }
+
+#define otbAppLogWARNING(x) \
+  { \
+  std::ostringstream message; \
+  message << "" x << std::endl; \
+  this->GetLogger()->Write( itk::LoggerBase::WARNING, message.str() ); \
+  }
+
+#define otbAppLogINFO(x) \
+  { \
+  std::ostringstream message; \
+  message << "" x << std::endl; \
+  this->GetLogger()->Write( itk::LoggerBase::INFO, message.str() ); \
+  }
+
+#define otbAppLogDEBUG(x) \
+  { \
+  std::ostringstream message; \
+  message << "" x << std::endl; \
+  this->GetLogger()->Write( itk::LoggerBase::DEBUG, message.str() ); \
+  }
+
+#endif
-- 
GitLab