From 0c6daebdc47e61076106f54019a929f1ef0fb0c7 Mon Sep 17 00:00:00 2001
From: Nick Draper <nick.draper@stfc.ac.uk>
Date: Mon, 24 Nov 2014 10:45:55 +0000
Subject: [PATCH] re #10550 initial code changes

---
 .../Framework/API/inc/MantidAPI/Algorithm.h   |  5 +++
 .../API/inc/MantidAPI/AlgorithmProxy.h        |  5 +++
 .../Framework/API/inc/MantidAPI/IAlgorithm.h  |  4 +++
 Code/Mantid/Framework/API/src/Algorithm.cpp   | 31 ++++++++++++++++---
 .../Framework/API/src/AlgorithmProxy.cpp      | 16 +++++++++-
 5 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h b/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h
index 5166e98be7e..c387e40dc95 100644
--- a/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h
+++ b/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h
@@ -239,6 +239,10 @@ public:
   void setLoggingOffset(const int value) { g_log.setLevelOffset(value); }
   ///returns the logging priority offset
   int getLoggingOffset() const { return g_log.getLevelOffset(); }
+  /// disable Logging of start and end messages
+  void setAlgStartupLogging(const bool enabled);  
+  /// get the state of Logging of start and end messages
+  bool getAlgStartupLogging() const;
 
   ///setting the child start progress
   void setChildStartProgress(const double startProgress)const{m_startChildProgress=startProgress;}
@@ -380,6 +384,7 @@ private:
   bool m_runningAsync; ///< Algorithm is running asynchronously
   bool m_running; ///< Algorithm is running
   bool m_rethrow; ///< Algorithm should rethrow exceptions while executing
+  bool m_isAlgStartupLoggingEnabled; /// Whether to log alg startup and closedown messages from the base class (default = true)
   mutable double m_startChildProgress; ///< Keeps value for algorithm's progress at start of an Child Algorithm
   mutable double m_endChildProgress; ///< Keeps value for algorithm's progress at Child Algorithm's finish
   AlgorithmID m_algorithmID; ///< Algorithm ID for managed algorithms
diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h
index 182878ba1eb..fadf11ba92e 100644
--- a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h
+++ b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h
@@ -131,6 +131,10 @@ namespace Mantid
       void setLoggingOffset(const int value)  { m_loggingOffset=value; }
       ///returns the logging priority offset
       int getLoggingOffset() const { return m_loggingOffset; }
+      /// disable Logging of start and end messages
+      void setAlgStartupLogging(const bool enabled);
+      /// get the state of Logging of start and end messages
+      bool getAlgStartupLogging() const;
 
       ///setting the child start progress
       void setChildStartProgress(const double startProgress)const;
@@ -171,6 +175,7 @@ namespace Mantid
       bool m_isExecuted;     ///< Executed flag
       bool m_isLoggingEnabled;///< is the logging of the underlying algorithm enabled
       int m_loggingOffset; ///< the logging priority offset
+      bool m_isAlgStartupLoggingEnabled; /// Whether to log alg startup and closedown messages from the base class (default = true)
       bool m_rethrow; ///< Whether or not to rethrow exceptions.
       bool m_isChild; ///< Is this a child algo
 
diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IAlgorithm.h b/Code/Mantid/Framework/API/inc/MantidAPI/IAlgorithm.h
index ec14a1fea68..01e34ad0e1f 100644
--- a/Code/Mantid/Framework/API/inc/MantidAPI/IAlgorithm.h
+++ b/Code/Mantid/Framework/API/inc/MantidAPI/IAlgorithm.h
@@ -156,6 +156,10 @@ public:
   virtual void setLoggingOffset(const int value) = 0;
   ///returns the logging priority offset
   virtual int getLoggingOffset() const = 0;
+  /// disable Logging of start and end messages
+  virtual void setAlgStartupLogging(const bool enabled) = 0;
+  /// get the state of Logging of start and end messages
+  virtual bool getAlgStartupLogging() const = 0;
   ///setting the child start progress
   virtual void setChildStartProgress(const double startProgress)const = 0;
   /// setting the child end progress
diff --git a/Code/Mantid/Framework/API/src/Algorithm.cpp b/Code/Mantid/Framework/API/src/Algorithm.cpp
index 591e7aee085..fe423171bea 100644
--- a/Code/Mantid/Framework/API/src/Algorithm.cpp
+++ b/Code/Mantid/Framework/API/src/Algorithm.cpp
@@ -84,7 +84,8 @@ namespace Mantid
       m_progressObserver(NULL),
       m_isInitialized(false), m_isExecuted(false),m_isChildAlgorithm(false), m_recordHistoryForChild(false),
       m_alwaysStoreInADS(false),m_runningAsync(false),
-      m_running(false), m_rethrow(false), m_algorithmID(this), m_singleGroup(-1), m_groupsHaveSimilarNames(false)
+      m_running(false), m_rethrow(false), m_isAlgStartupLoggingEnabled(true),
+      m_algorithmID(this), m_singleGroup(-1), m_groupsHaveSimilarNames(false)
     {
     }
 
@@ -1034,6 +1035,7 @@ namespace Mantid
       m_algorithmID = proxy.getAlgorithmID();
       setLogging(proxy.isLogging());
       setLoggingOffset(proxy.getLoggingOffset());
+      setAlgStartupLogging(proxy.getAlgStartupLogging());
       setChild(proxy.isChild());
     }
 
@@ -1209,7 +1211,10 @@ namespace Mantid
     {
       auto & logger = getLogger();
 
-      logger.notice() << name() << " started";
+      if (m_isAlgStartupLoggingEnabled)
+      {
+        logger.notice() << name() << " started";
+      }
       if (this->isChild())
         logger.notice() << " (child)";
       logger.notice() << std::endl;
@@ -1662,8 +1667,11 @@ namespace Mantid
 
       if (!m_isChildAlgorithm || m_alwaysStoreInADS)
       {
-        getLogger().notice() << name() << " successful, Duration "
-              << std::fixed << std::setprecision(2) << duration << " seconds" << optionalMessage << std::endl;
+        if (m_isAlgStartupLoggingEnabled)
+        {
+          getLogger().notice() << name() << " successful, Duration "
+                << std::fixed << std::setprecision(2) << duration << " seconds" << optionalMessage << std::endl;
+        }
       }
       
       else
@@ -1673,8 +1681,21 @@ namespace Mantid
       m_running = false;
     }
 
+    /** Enable or disable Logging of start and end messages
+    @param enabled : true to enable logging, false to disable
+    */ 
+    void Algorithm::setAlgStartupLogging(const bool enabled) 
+    {
+      m_isAlgStartupLoggingEnabled = enabled;
+    }
 
-
+    /** return the state of logging of start and end messages
+    @returns : true to logging is enabled
+    */ 
+    bool Algorithm::getAlgStartupLogging() const
+    {
+      return m_isAlgStartupLoggingEnabled;
+    }
   } // namespace API
 
   //---------------------------------------------------------------------------
diff --git a/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp b/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp
index 28253008fce..8291eb87ae8 100644
--- a/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp
+++ b/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp
@@ -26,7 +26,7 @@ namespace Mantid
     PropertyManagerOwner(), m_executeAsync(new Poco::ActiveMethod<bool, Poco::Void, AlgorithmProxy>(this,&AlgorithmProxy::executeAsyncImpl)),
       m_name(alg->name()),m_category(alg->category()), m_categorySeparator(alg->categorySeparator()),
       m_alias(alg->alias()),m_summary(alg->summary()), m_version(alg->version()), m_alg(alg),
-      m_isExecuted(),m_isLoggingEnabled(true), m_loggingOffset(0), m_rethrow(false),
+      m_isExecuted(),m_isLoggingEnabled(true), m_loggingOffset(0), m_isAlgStartupLoggingEnabled(true), m_rethrow(false),
       m_isChild(false)
     {
       if (!alg)
@@ -334,6 +334,20 @@ namespace Mantid
       return res;
     }
 
+    /** Enable or disable Logging of start and end messages
+    @param enabled : true to enable logging, false to disable
+    */ 
+    void AlgorithmProxy::setAlgStartupLogging(const bool enabled) 
+    {
+      m_isAlgStartupLoggingEnabled = enabled;
+    }
 
+    /** return the state of logging of start and end messages
+    @returns : true to logging is enabled
+    */ 
+    bool AlgorithmProxy::getAlgStartupLogging() const
+    {
+      return m_isAlgStartupLoggingEnabled;
+    }
   } // namespace API
 } // namespace Mantid
-- 
GitLab