From c99e3ae2212d7009de7a1a529cca3e6cdc367564 Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@stfc.ac.uk> Date: Tue, 18 Mar 2014 08:50:34 +0000 Subject: [PATCH] API & APITest compiles. Refs #9059 --- Code/Mantid/Framework/API/CMakeLists.txt | 1 - .../Framework/API/inc/MantidAPI/Algorithm.h | 20 +++--- .../API/inc/MantidAPI/AlgorithmFactory.h | 3 - .../API/inc/MantidAPI/AlgorithmManager.h | 3 - .../API/inc/MantidAPI/AlgorithmProxy.h | 3 - .../API/inc/MantidAPI/CatalogFactory.h | 10 --- .../Framework/API/inc/MantidAPI/Column.h | 11 --- .../API/inc/MantidAPI/ColumnFactory.h | 17 +---- .../API/inc/MantidAPI/ConstraintFactory.h | 14 +--- .../API/inc/MantidAPI/CostFunctionFactory.h | 3 - .../API/inc/MantidAPI/ExperimentInfo.h | 3 - .../Framework/API/inc/MantidAPI/FileFinder.h | 12 ++-- .../API/inc/MantidAPI/FileLoaderRegistry.h | 2 +- .../API/inc/MantidAPI/FrameworkManager.h | 8 --- .../API/inc/MantidAPI/FuncMinimizerFactory.h | 3 - .../API/inc/MantidAPI/FunctionFactory.h | 11 --- .../API/inc/MantidAPI/FunctionProperty.h | 4 -- .../Framework/API/inc/MantidAPI/GridDomain.h | 4 -- .../Framework/API/inc/MantidAPI/IFunction.h | 4 -- .../Framework/API/inc/MantidAPI/IFunction1D.h | 3 - .../Framework/API/inc/MantidAPI/IFunctionMD.h | 4 -- .../Framework/API/inc/MantidAPI/IFunctionMW.h | 4 -- .../API/inc/MantidAPI/ITableWorkspace.h | 10 --- .../API/inc/MantidAPI/ITransformScale.h | 4 -- .../API/inc/MantidAPI/LiveListenerFactory.h | 3 - .../Framework/API/inc/MantidAPI/LogManager.h | 2 - .../API/inc/MantidAPI/MatrixWorkspace.h | 3 - .../API/inc/MantidAPI/MemoryManager.h | 4 -- .../API/inc/MantidAPI/MultipleFileProperty.h | 4 -- Code/Mantid/Framework/API/inc/MantidAPI/Run.h | 2 - .../inc/MantidAPI/ScriptRepositoryFactory.h | 12 ---- .../Framework/API/inc/MantidAPI/TableRow.h | 16 +---- .../API/inc/MantidAPI/TransformScaleFactory.h | 2 - .../API/inc/MantidAPI/WorkspaceFactory.h | 3 - .../API/inc/MantidAPI/WorkspaceGroup.h | 12 ---- .../API/inc/MantidAPI/WorkspaceHistory.h | 15 ++-- .../API/inc/MantidAPI/WorkspaceProperty.h | 4 +- Code/Mantid/Framework/API/src/Algorithm.cpp | 69 +++++++++---------- .../Framework/API/src/AlgorithmFactory.cpp | 10 ++- .../Framework/API/src/AlgorithmManager.cpp | 8 ++- .../Framework/API/src/AlgorithmProxy.cpp | 4 -- .../Framework/API/src/CatalogFactory.cpp | 3 +- Code/Mantid/Framework/API/src/Column.cpp | 8 ++- .../Framework/API/src/ColumnFactory.cpp | 26 +++---- .../Framework/API/src/CompositeFunction.cpp | 10 ++- .../Framework/API/src/ConstraintFactory.cpp | 4 +- .../Framework/API/src/CostFunctionFactory.cpp | 4 +- .../API/src/DataProcessorAlgorithm.cpp | 2 +- .../Framework/API/src/ExperimentInfo.cpp | 7 +- Code/Mantid/Framework/API/src/FileFinder.cpp | 5 +- .../Framework/API/src/FileLoaderRegistry.cpp | 2 +- .../Framework/API/src/FrameworkManager.cpp | 15 ++-- .../API/src/FuncMinimizerFactory.cpp | 5 +- .../Framework/API/src/FunctionFactory.cpp | 4 +- .../Framework/API/src/FunctionProperty.cpp | 2 - Code/Mantid/Framework/API/src/GridDomain.cpp | 9 ++- Code/Mantid/Framework/API/src/IFunction.cpp | 8 ++- Code/Mantid/Framework/API/src/IFunction1D.cpp | 1 - Code/Mantid/Framework/API/src/IFunctionMD.cpp | 4 -- Code/Mantid/Framework/API/src/IFunctionMW.cpp | 2 - .../API/src/IPowderDiffPeakFunction.cpp | 2 - .../Framework/API/src/ITableWorkspace.cpp | 4 -- .../Framework/API/src/ITransformScale.cpp | 14 ---- .../Framework/API/src/LiveListenerFactory.cpp | 12 ++-- Code/Mantid/Framework/API/src/LogManager.cpp | 7 +- .../Framework/API/src/LogarithmScale.cpp | 7 ++ .../Framework/API/src/MatrixWorkspace.cpp | 17 +++-- .../Framework/API/src/MemoryManager.cpp | 7 +- .../API/src/MultiPeriodGroupAlgorithm.cpp | 1 - .../API/src/MultipleFileProperty.cpp | 6 +- .../Framework/API/src/ParamFunction.cpp | 6 ++ Code/Mantid/Framework/API/src/Run.cpp | 7 +- .../API/src/ScriptRepositoryFactory.cpp | 4 +- Code/Mantid/Framework/API/src/TableRow.cpp | 4 -- .../API/src/TransformScaleFactory.cpp | 9 ++- .../Framework/API/src/WorkspaceFactory.cpp | 13 ++-- .../Framework/API/src/WorkspaceGroup.cpp | 12 ++-- .../Framework/API/src/WorkspaceHistory.cpp | 11 +-- 78 files changed, 224 insertions(+), 374 deletions(-) delete mode 100644 Code/Mantid/Framework/API/src/ITransformScale.cpp diff --git a/Code/Mantid/Framework/API/CMakeLists.txt b/Code/Mantid/Framework/API/CMakeLists.txt index 8835e9543d7..389917ad700 100644 --- a/Code/Mantid/Framework/API/CMakeLists.txt +++ b/Code/Mantid/Framework/API/CMakeLists.txt @@ -62,7 +62,6 @@ set ( SRC_FILES src/ISpectrum.cpp src/ISplittersWorkspace.cpp src/ITableWorkspace.cpp - src/ITransformScale.cpp src/IkedaCarpenterModerator.cpp src/ImmutableCompositeFunction.cpp src/ImplicitFunctionParameterParserFactory.cpp diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h b/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h index 2d073e8c5ac..5ee253389da 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h @@ -224,18 +224,17 @@ public: /// Returns the cancellation state bool getCancel() const { return m_cancel; } + /// Returns a reference to the logger. + Kernel::Logger & getLogger() const { return g_log; } ///Logging can be disabled by passing a value of false - void setLogging(const bool value){g_log.setEnabled(value);} + void setLogging(const bool value) { g_log.setEnabled(value);} ///returns the status of logging, True = enabled - bool isLogging() const {return g_log.getEnabled();} + bool isLogging() const { return g_log.getEnabled();} ///sets the logging priority offset - void setLoggingOffset(const int value) {g_log.setLevelOffset(value);} + void setLoggingOffset(const int value) { g_log.setLevelOffset(value); } ///returns the logging priority offset - int getLoggingOffset() const {return g_log.getLevelOffset();} - - /// Returns a reference to the logger. - Kernel::Logger& getLogger() const { return g_log; } + int getLoggingOffset() const { return g_log.getLevelOffset(); } /// function returns an optional message that will be displayed in the default GUI, at the top. @@ -318,8 +317,6 @@ protected: bool m_cancel; /// Set if an exception is thrown, and not caught, within a parallel region bool m_parallelException; - /// Reference to the logger class - Kernel::Logger& g_log; friend class WorkspaceHistory; // Allow workspace history loading to adjust g_execCount static size_t g_execCount; ///< Counter to keep track of algorithm execution order @@ -338,6 +335,10 @@ protected: /// All the WorkspaceProperties that are Input or InOut. Set in execute() std::vector<IWorkspaceProperty *> m_inputWorkspaceProps; + /// Logger for this algorithm + Kernel::Logger m_log; + Kernel::Logger &g_log; + private: /// Private Copy constructor: NO COPY ALLOWED Algorithm(const Algorithm&); @@ -355,7 +356,6 @@ private: bool executeAsyncImpl(const Poco::Void & i); // --------------------- Private Members ----------------------------------- - /// Poco::ActiveMethod used to implement asynchronous execution. Poco::ActiveMethod<bool, Poco::Void, Algorithm, Poco::ActiveStarter<Algorithm>> *m_executeAsync; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmFactory.h b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmFactory.h index 0c71e9cfb22..e6c392769e6 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmFactory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmFactory.h @@ -10,7 +10,6 @@ #include "MantidAPI/DllConfig.h" #include "MantidKernel/DynamicFactory.h" #include "MantidKernel/SingletonHolder.h" -#include "MantidKernel/Logger.h" namespace Mantid { @@ -158,8 +157,6 @@ public: std::string createName(const std::string&, const int&)const; /// fills a set with the hidden categories void fillHiddenCategories(std::set<std::string> *categorySet) const; - ///static reference to the logger class - Kernel::Logger& g_log; /// A typedef for the map of algorithm versions typedef std::map<std::string, int> VersionMap; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmManager.h b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmManager.h index 0770c385c98..68e8592da1d 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmManager.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmManager.h @@ -8,7 +8,6 @@ #include <string> #include <Poco/NotificationCenter.h> #include "MantidAPI/DllConfig.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/SingletonHolder.h" #include "MantidAPI/Algorithm.h" @@ -91,8 +90,6 @@ private: /// Unimplemented assignment operator AlgorithmManagerImpl& operator =(const AlgorithmManagerImpl&); - /// Reference to the logger class - Kernel::Logger& g_log; /// The maximum size of the algorithm store int m_max_no_algs; /// The list of managed algorithms diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h index d4fbc1c89cb..032ce3f6c3b 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h @@ -185,9 +185,6 @@ namespace Mantid /// Temporary holder of external observers wishing to subscribe mutable std::vector<const Poco::AbstractObserver*> m_externalObservers; - - /// Static refenence to the logger class - static Kernel::Logger& g_log; }; } // namespace API diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/CatalogFactory.h b/Code/Mantid/Framework/API/inc/MantidAPI/CatalogFactory.h index 43876ecedea..e0fa8a3ddc9 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/CatalogFactory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/CatalogFactory.h @@ -25,14 +25,6 @@ namespace Mantid { - //---------------------------------------------------------------------- - // Forward declaration - //---------------------------------------------------------------------- - namespace Kernel - { - class Logger; - } - namespace API { //---------------------------------------------------------------------- @@ -79,8 +71,6 @@ namespace Mantid virtual ~CatalogFactoryImpl(); /// Stores pointers to already created Catalog instances, with their name as the key mutable std::map< std::string, boost::shared_ptr<ICatalog> > m_createdCatalogs; - /// Reference to the logger class - Kernel::Logger& m_log; }; ///Forward declaration of a specialisation of SingletonHolder for CatalogFactoryImpl (needed for dllexport/dllimport) . diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/Column.h b/Code/Mantid/Framework/API/inc/MantidAPI/Column.h index 7b3fec201cf..a5d2f4e206a 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/Column.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/Column.h @@ -5,7 +5,6 @@ // Includes //---------------------------------------------------------------------- #include "MantidAPI/DllConfig.h" -#include "MantidKernel/Logger.h" #include <boost/shared_ptr.hpp> #include <string> @@ -16,14 +15,6 @@ namespace Mantid { -//---------------------------------------------------------------------- -// Forward declarations -//---------------------------------------------------------------------- -namespace Kernel -{ - class Logger; -} - namespace API { /** \class Column @@ -188,8 +179,6 @@ protected: friend class ColumnFactoryImpl; friend class ITableWorkspace; template<class T> friend class ColumnVector; - /// Logger - static Kernel::Logger& g_log; }; /** @class Boolean diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/ColumnFactory.h b/Code/Mantid/Framework/API/inc/MantidAPI/ColumnFactory.h index ef899f74902..ede2a739c2c 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/ColumnFactory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/ColumnFactory.h @@ -11,22 +11,13 @@ namespace Mantid { - -//---------------------------------------------------------------------- -// Forward declarations -//---------------------------------------------------------------------- -namespace Kernel -{ - class Logger; -} namespace API { + //---------------------------------------------------------------------- + // Forward declarations + //---------------------------------------------------------------------- class Column; -} - -namespace API -{ /** @class ColumnFactoryImpl @@ -74,8 +65,6 @@ namespace API ColumnFactoryImpl& operator = (const ColumnFactoryImpl&); ///Private Destructor virtual ~ColumnFactoryImpl(); - ///static reference to the logger class - Kernel::Logger& g_log; }; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/ConstraintFactory.h b/Code/Mantid/Framework/API/inc/MantidAPI/ConstraintFactory.h index 3c853199974..afa75eb41e5 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/ConstraintFactory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/ConstraintFactory.h @@ -11,20 +11,12 @@ namespace Mantid { - -//---------------------------------------------------------------------- -// Forward declarations -//---------------------------------------------------------------------- -namespace Kernel -{ - class Logger; -} namespace API { //---------------------------------------------------------------------- -// More forward declarations +// Forward declarations //---------------------------------------------------------------------- class IConstraint; class IFunction; @@ -79,10 +71,6 @@ namespace API ConstraintFactoryImpl& operator = (const ConstraintFactoryImpl&); ///Private Destructor virtual ~ConstraintFactoryImpl(); - - ///static reference to the logger class - Kernel::Logger& g_log; - }; ///Forward declaration of a specialisation of SingletonHolder for AlgorithmFactoryImpl (needed for dllexport/dllimport) and a typedef for it. diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/CostFunctionFactory.h b/Code/Mantid/Framework/API/inc/MantidAPI/CostFunctionFactory.h index d129ceda1c8..a8d62acd6f7 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/CostFunctionFactory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/CostFunctionFactory.h @@ -63,9 +63,6 @@ namespace API friend struct Mantid::Kernel::CreateUsingNew<CostFunctionFactoryImpl>; /// Private Constructor for singleton class CostFunctionFactoryImpl(); - - ///static reference to the logger class - Kernel::Logger& g_log; }; ///Forward declaration of a specialisation of SingletonHolder for AlgorithmFactoryImpl (needed for dllexport/dllimport) and a typedef for it. diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h b/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h index b98ec1742dd..41e5e65a0a5 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h @@ -137,9 +137,6 @@ namespace API protected: - /// Static reference to the logger class - static Kernel::Logger& g_log; - /// Description of the source object boost::shared_ptr<ModeratorModel> m_moderatorModel; /// Description of the choppers for this experiment. diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/FileFinder.h b/Code/Mantid/Framework/API/inc/MantidAPI/FileFinder.h index e8fe86c9622..8f4b3b78ebc 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/FileFinder.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/FileFinder.h @@ -4,8 +4,6 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- -#include "MantidKernel/Logger.h" -#include "MantidKernel/InstrumentInfo.h" #include "MantidKernel/SingletonHolder.h" #include "MantidAPI/DllConfig.h" #include "MantidAPI/IArchiveSearch.h" @@ -15,6 +13,13 @@ namespace Mantid { + //--------------------------------------------------------------------------- + // Forward declarations + //--------------------------------------------------------------------------- + namespace Kernel + { + class InstrumentInfo; + } namespace API { @@ -80,9 +85,6 @@ namespace Mantid std::string toUpper(const std::string &src) const; /// glob option - set to case sensitive or insensitive int m_globOption; - - /// reference to the logger class - Mantid::Kernel::Logger& g_log; }; ///Forward declaration of a specialisation of SingletonHolder for AlgorithmFactoryImpl (needed for dllexport/dllimport) and a typedef for it. diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/FileLoaderRegistry.h b/Code/Mantid/Framework/API/inc/MantidAPI/FileLoaderRegistry.h index 9707f11d361..3c357f37bc6 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/FileLoaderRegistry.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/FileLoaderRegistry.h @@ -134,7 +134,7 @@ namespace Mantid size_t m_totalSize; /// Reference to a logger - Kernel::Logger & m_log; + mutable Kernel::Logger m_log; }; ///Forward declaration of a specialisation of SingletonHolder for FileLoaderRegistryImpl (needed for dllexport/dllimport) and a typedef for it. diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/FrameworkManager.h b/Code/Mantid/Framework/API/inc/MantidAPI/FrameworkManager.h index 3fb03f3ea06..8224575367a 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/FrameworkManager.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/FrameworkManager.h @@ -18,11 +18,6 @@ namespace Mantid { - namespace Kernel - { - class Logger; - } - namespace API { //---------------------------------------------------------------------- @@ -117,9 +112,6 @@ namespace Mantid /// Silence NeXus output void disableNexusOutput(); - /// Reference to the logger class - Kernel::Logger& g_log; - #ifdef MPI_BUILD /** Member variable that initialises the MPI environment on construction (in the * FrameworkManager constructor) and finalises it on destruction. diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/FuncMinimizerFactory.h b/Code/Mantid/Framework/API/inc/MantidAPI/FuncMinimizerFactory.h index c490bb313bc..9b6203020fc 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/FuncMinimizerFactory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/FuncMinimizerFactory.h @@ -59,9 +59,6 @@ namespace API friend struct Mantid::Kernel::CreateUsingNew<FuncMinimizerFactoryImpl>; /// Private Constructor for singleton class FuncMinimizerFactoryImpl(); - - ///static reference to the logger class - Kernel::Logger& g_log; }; ///Forward declaration of a specialisation of SingletonHolder for AlgorithmFactoryImpl (needed for dllexport/dllimport) and a typedef for it. diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/FunctionFactory.h b/Code/Mantid/Framework/API/inc/MantidAPI/FunctionFactory.h index b9fed8c63c8..8286452725a 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/FunctionFactory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/FunctionFactory.h @@ -15,14 +15,6 @@ namespace Mantid { - -//---------------------------------------------------------------------- -// Forward declarations -//---------------------------------------------------------------------- -namespace Kernel -{ - class Logger; -} namespace API { @@ -124,9 +116,6 @@ namespace API /// Add a tie to the created function void addTie(boost::shared_ptr<IFunction> fun,const Expression& expr)const; - /// Reference to the logger class - Kernel::Logger& g_log; - mutable std::map<std::string,std::vector<std::string>> m_cachedFunctionNames; mutable Kernel::Mutex m_mutex; }; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/FunctionProperty.h b/Code/Mantid/Framework/API/inc/MantidAPI/FunctionProperty.h index eba0b6c6c55..b4afdbd516e 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/FunctionProperty.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/FunctionProperty.h @@ -7,7 +7,6 @@ #include "MantidAPI/DllConfig.h" #include "MantidAPI/IFunction.h" #include "MantidKernel/PropertyWithValue.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/Exception.h" #include <boost/shared_ptr.hpp> @@ -90,9 +89,6 @@ namespace Mantid /// The function definition string (as used by the FunctionFactory) std::string m_definition; - - /// for access to logging streams - static Kernel::Logger& g_log; }; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/GridDomain.h b/Code/Mantid/Framework/API/inc/MantidAPI/GridDomain.h index a08288b2f78..a353d13880e 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/GridDomain.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/GridDomain.h @@ -9,7 +9,6 @@ #include "MantidAPI/DllConfig.h" #include "MantidAPI/FunctionDomain.h" -#include "MantidKernel/Logger.h" namespace Mantid { @@ -56,9 +55,6 @@ public: /// re-scale all grids void reScale( const std::string &scaling); -protected: - static Kernel::Logger& g_log; - private: /// composition of grids std::vector< boost::shared_ptr<GridDomain> > m_grids; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IFunction.h b/Code/Mantid/Framework/API/inc/MantidAPI/IFunction.h index 6027de4d263..a18a13d200a 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IFunction.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IFunction.h @@ -10,7 +10,6 @@ #include "MantidAPI/FunctionValues.h" #include "MantidAPI/Jacobian.h" #include "MantidKernel/Matrix.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Unit.h" @@ -483,9 +482,6 @@ protected: /// Pointer to the progress handler Kernel::ProgressBase *m_progReporter; - /// Static reference to the logger class - static Kernel::Logger& g_log; - private: /// The declared attributes std::map<std::string, API::IFunction::Attribute> m_attrs; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IFunction1D.h b/Code/Mantid/Framework/API/inc/MantidAPI/IFunction1D.h index d07c5b814ac..b8efedd66d4 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IFunction1D.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IFunction1D.h @@ -77,9 +77,6 @@ public: protected: - /// Static reference to the logger class - static Kernel::Logger& g_log; - /// Making a friend friend class CurveFitting::Fit; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IFunctionMD.h b/Code/Mantid/Framework/API/inc/MantidAPI/IFunctionMD.h index 6fd400a2616..233788ffa19 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IFunctionMD.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IFunctionMD.h @@ -92,10 +92,6 @@ protected: /// dimensions used in this function in the expected order std::vector< boost::shared_ptr<const Mantid::Geometry::IMDDimension> > m_dimensions; - - /// Static reference to the logger class - static Kernel::Logger& g_log; - private: /// Use all the dimensions in the workspace virtual void useAllDimensions(boost::shared_ptr<const IMDWorkspace> workspace); diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IFunctionMW.h b/Code/Mantid/Framework/API/inc/MantidAPI/IFunctionMW.h index 786348415c2..d92b3bf1d27 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IFunctionMW.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IFunctionMW.h @@ -56,10 +56,6 @@ protected: boost::weak_ptr<const API::MatrixWorkspace> m_workspace; /// An index to a spectrum size_t m_workspaceIndex; - - /// Static reference to the logger class - static Kernel::Logger& g_log; - }; } // namespace API diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/ITableWorkspace.h b/Code/Mantid/Framework/API/inc/MantidAPI/ITableWorkspace.h index b2c0faef5a0..8d91ba48a77 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/ITableWorkspace.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/ITableWorkspace.h @@ -20,10 +20,6 @@ namespace Mantid //---------------------------------------------------------------------- // Forward declarations //---------------------------------------------------------------------- -namespace Kernel -{ - class Logger; -} namespace API { @@ -204,7 +200,6 @@ public: { std::string str = std::string("getRef: Type mismatch. ") + typeid(T).name() + " != " + c->get_type_info().name() + '\n'; - g_log.error(str); throw std::runtime_error(str); } return *(static_cast<T*>(c->void_pointer(index))); @@ -225,7 +220,6 @@ public: { std::ostringstream ostr; ostr << "cell: Type mismatch:\n"<<typeid(T).name()<<" != \n"<<c->get_type_info().name()<<'\n'; - g_log.error(ostr.str()); throw std::runtime_error(ostr.str()); } if (row >= this->rowCount()) @@ -317,10 +311,6 @@ protected: { c->remove(index); } -private: - /// Logger - static Kernel::Logger& g_log; - }; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/ITransformScale.h b/Code/Mantid/Framework/API/inc/MantidAPI/ITransformScale.h index 9f3174eac28..f07637c558b 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/ITransformScale.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/ITransformScale.h @@ -8,7 +8,6 @@ #include <vector> #include "MantidAPI/DllConfig.h" -#include "MantidKernel/Logger.h" namespace Mantid { @@ -49,9 +48,6 @@ public: virtual const std::string name() const { return "ITransformScale"; } /// The scaling transformation. Define in derived classes virtual void transform( std::vector<double> &gd ) = 0; - -protected: - static Kernel::Logger& g_log; }; // class ITransformScale /// typedef for a shared pointer diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/LiveListenerFactory.h b/Code/Mantid/Framework/API/inc/MantidAPI/LiveListenerFactory.h index db8bbbda691..a5c453a3f57 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/LiveListenerFactory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/LiveListenerFactory.h @@ -69,9 +69,6 @@ namespace Mantid using Kernel::DynamicFactory<ILiveListener>::create; /// Override the DynamicFactory::createUnwrapped() method. We don't want it used here. ILiveListener* createUnwrapped(const std::string& className) const; - - /// Reference to the logger class - Kernel::Logger& m_log; }; ///Forward declaration of a specialisation of SingletonHolder (needed for dllexport/dllimport). diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/LogManager.h b/Code/Mantid/Framework/API/inc/MantidAPI/LogManager.h index b3bf17d51ba..f717d6334a6 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/LogManager.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/LogManager.h @@ -152,8 +152,6 @@ namespace Mantid virtual void loadNexus(::NeXus::File * file, const std::string & group,bool keepOpen=false); protected: - /// Static reference to the logger class - static Kernel::Logger &g_log; /// A pointer to a property manager Kernel::PropertyManager m_manager; /// Name of the log entry containing the proton charge when retrieved using getProtonCharge diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h b/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h index 7183da5e5f7..7ed4714fb96 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h @@ -340,9 +340,6 @@ namespace Mantid /// Shared pointer to NearestNeighbours object mutable boost::shared_ptr<Mantid::Geometry::INearestNeighbours> m_nearestNeighbours; - /// Static reference to the logger class - static Kernel::Logger& g_log; - /// Getter for the dimension id based on the axis. std::string getDimensionIdFromAxis(const int& axisIndex) const; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/MemoryManager.h b/Code/Mantid/Framework/API/inc/MantidAPI/MemoryManager.h index baf596fd8c9..5e29cbf3c06 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/MemoryManager.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/MemoryManager.h @@ -5,7 +5,6 @@ // Includes //---------------------------------------------------------------------- #include "MantidAPI/DllConfig.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/MultiThreaded.h" #include "MantidKernel/SingletonHolder.h" @@ -75,9 +74,6 @@ namespace Mantid /// Standard Assignment operator MemoryManagerImpl& operator = (const MemoryManagerImpl&); - /// Static reference to the logger class - Kernel::Logger& g_log; - /** Amount of memory (in bytes) that has been cleared but perhaps not released. * releaseFreeMemoryIfAccumulated() uses this value */ diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/MultipleFileProperty.h b/Code/Mantid/Framework/API/inc/MantidAPI/MultipleFileProperty.h index 9ecd69ccb71..f34f61754b5 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/MultipleFileProperty.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/MultipleFileProperty.h @@ -1,9 +1,7 @@ #ifndef MANTID_API_MULTIPLEFILEPROPERTY_H_ #define MANTID_API_MULTIPLEFILEPROPERTY_H_ -#include "MantidKernel/Logger.h" #include "MantidKernel/PropertyWithValue.h" -#include "MantidKernel/System.h" #include "MantidKernel/MultiFileNameParser.h" #include <vector> #include <set> @@ -138,8 +136,6 @@ namespace API Kernel::MultiFileNameParsing::Parser m_parser; ///The default file extension associated with the type of file this property will handle std::string m_defaultExt; - /// Reference to the logger class - Kernel::Logger& g_log; }; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/Run.h b/Code/Mantid/Framework/API/inc/MantidAPI/Run.h index 17ee476227f..a08bd315f15 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/Run.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/Run.h @@ -97,8 +97,6 @@ namespace Mantid /// Calculate the gonoimeter matrix void calculateGoniometerMatrix(); - /// Static reference to the logger class - static Kernel::Logger &g_log; /// Goniometer for this run Mantid::Geometry::Goniometer m_goniometer; /// A set of histograms that can be stored here for future reference diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/ScriptRepositoryFactory.h b/Code/Mantid/Framework/API/inc/MantidAPI/ScriptRepositoryFactory.h index 32b89d2cb25..b7b5799711d 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/ScriptRepositoryFactory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/ScriptRepositoryFactory.h @@ -14,14 +14,6 @@ namespace Mantid { -//---------------------------------------------------------------------- -// Forward declarations -//---------------------------------------------------------------------- -namespace Kernel -{ - class Logger; -} - namespace API { @@ -75,10 +67,6 @@ namespace API ScriptRepositoryFactoryImpl& operator = (const ScriptRepositoryFactoryImpl&); ///Private Destructor virtual ~ScriptRepositoryFactoryImpl(); - - ///static reference to the logger class - Kernel::Logger& g_log; - }; ///Forward declaration of a specialisation of SingletonHolder for AlgorithmFactoryImpl (needed for dllexport/dllimport) and a typedef for it. diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/TableRow.h b/Code/Mantid/Framework/API/inc/MantidAPI/TableRow.h index 8212e01c0e5..daa12f59e7d 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/TableRow.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/TableRow.h @@ -11,17 +11,11 @@ namespace Mantid { +namespace API +{ //---------------------------------------------------------------------- // Forward declarations //---------------------------------------------------------------------- -namespace Kernel -{ - class Logger; -} - -namespace API -{ - class TableRowHelper; /** \class TableRow @@ -80,14 +74,12 @@ public: { if (m_col >= m_columns.size()) { - g_log.error("Column index out of range."); throw std::range_error("Column index out of range."); } Column_sptr c = m_columns[m_col]; if (!c->isType<T>()) { std::string str = "Type mismatch. "; - g_log.error(str); throw std::runtime_error(str); } c->cell<T>(m_row) = t; @@ -111,7 +103,6 @@ public: { if (m_col >= m_columns.size()) { - g_log.error("Column index out of range."); throw std::range_error("Column index out of range."); } Column_sptr c = m_columns[m_col]; @@ -136,7 +127,6 @@ public: { if (col >= m_columns.size()) { - g_log.error("Column index out of range."); throw std::range_error("Column index out of range."); } m_col = col; @@ -176,8 +166,6 @@ private: mutable size_t m_col; ///< Current column number (for streaming operations) size_t m_nrows; ///< Number of rows in the TableWorkspace std::string m_sep; ///< Separator character(s) between elements in a text output - /// Logger - static Kernel::Logger& g_log; }; MANTID_API_DLL std::ostream& operator<<(std::ostream& s,const TableRow& row); diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/TransformScaleFactory.h b/Code/Mantid/Framework/API/inc/MantidAPI/TransformScaleFactory.h index 411e6cf8d61..a464bb2ba17 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/TransformScaleFactory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/TransformScaleFactory.h @@ -65,8 +65,6 @@ namespace Mantid TransformScaleFactoryImpl(const TransformScaleFactoryImpl&); /// Private assignment operator - NO ASSIGNMENT ALLOWED TransformScaleFactoryImpl& operator = (const TransformScaleFactoryImpl&); - ///reference to the logger class - Kernel::Logger& g_log; // Do not use default methods }; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceFactory.h b/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceFactory.h index 8420bd12fc0..2e665bd9b6a 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceFactory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceFactory.h @@ -92,9 +92,6 @@ private: // Unhide the inherited create method but make it private using Kernel::DynamicFactory<Workspace>::create; - - /// Static reference to the logger class - Kernel::Logger& g_log; }; ///Forward declaration of a specialisation of SingletonHolder for AlgorithmFactoryImpl (needed for dllexport/dllimport) and a typedef for it. diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceGroup.h b/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceGroup.h index c9cb7293c02..289f288ff4a 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceGroup.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceGroup.h @@ -13,14 +13,6 @@ namespace Mantid { -//---------------------------------------------------------------------- -// Forward Declarations -//---------------------------------------------------------------------- -namespace Kernel -{ - class Logger; -} - namespace API { //---------------------------------------------------------------------- @@ -137,10 +129,6 @@ private: bool m_observingADS; /// Recursive mutex to avoid simultaneous access mutable Poco::Mutex m_mutex; - /// Static reference to the logger - static Kernel::Logger& g_log; - /// Maximum allowed depth for nested groups. - static size_t g_maximum_depth; friend class AnalysisDataServiceImpl; friend class Algorithm; diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceHistory.h b/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceHistory.h index aa91fc6cdee..2646f715697 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceHistory.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceHistory.h @@ -6,11 +6,17 @@ //---------------------------------------------------------------------- #include "MantidAPI/AlgorithmHistory.h" #include "MantidKernel/EnvironmentHistory.h" -#include <nexus/NeXusFile.hpp> #include <boost/shared_ptr.hpp> #include <ctime> -#include <list> -#include "MantidKernel/Logger.h" +#include <set> + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +namespace NeXus +{ + class File; +} namespace Mantid { @@ -93,9 +99,6 @@ private: /// The algorithms which have been called on the workspace AlgorithmHistories m_algorithms; - /// Reference to the logger class - Kernel::Logger& g_log; - }; MANTID_API_DLL std::ostream& operator<<(std::ostream&, const WorkspaceHistory&); diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceProperty.h b/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceProperty.h index 9f8e259e600..20b4fb49570 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceProperty.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceProperty.h @@ -511,11 +511,11 @@ namespace Mantid LockMode::Type m_locking; /// for access to logging streams - static Kernel::Logger& g_log; + static Kernel::Logger g_log; }; template <typename TYPE> - Kernel::Logger& WorkspaceProperty<TYPE>::g_log = Kernel::Logger::get("WorkspaceProperty"); + Kernel::Logger WorkspaceProperty<TYPE>::g_log("WorkspaceProperty"); } // namespace API } // namespace Mantid diff --git a/Code/Mantid/Framework/API/src/Algorithm.cpp b/Code/Mantid/Framework/API/src/Algorithm.cpp index 800f78aff5e..2e33734c48b 100644 --- a/Code/Mantid/Framework/API/src/Algorithm.cpp +++ b/Code/Mantid/Framework/API/src/Algorithm.cpp @@ -77,7 +77,7 @@ namespace Mantid /// Constructor Algorithm::Algorithm() : PropertyManagerOwner(), - m_cancel(false),m_parallelException(false),g_log(Kernel::Logger::get("Algorithm")), + m_cancel(false),m_parallelException(false), m_log("Algorithm"), g_log(m_log), m_executeAsync(NULL), m_notificationCenter(NULL), m_progressObserver(NULL), @@ -95,7 +95,6 @@ namespace Mantid delete m_executeAsync; delete m_progressObserver; - g_log.release(); // Free up any memory available. Mantid::API::MemoryManager::Instance().releaseFreeMemory(); } @@ -302,7 +301,6 @@ namespace Mantid } catch(std::runtime_error& ex) { - g_log.error() << "Error initializing " << this->name() << " algorithm: " << ex.what() << std::endl; throw; } @@ -319,7 +317,7 @@ namespace Mantid { // Gaudi: A call to the auditor service is here // (1) perform the printout - g_log.fatal("UNKNOWN Exception is caught in initialize()"); + getLogger().fatal("UNKNOWN Exception is caught in initialize()"); throw; } @@ -397,6 +395,7 @@ namespace Mantid throw std::logic_error("Algorithm::lockWorkspaces(): The workspaces have already been locked!"); // First, Write-lock the output workspaces + auto & debugLog = g_log.debug(); for (size_t i=0; i<m_outputWorkspaceProps.size(); i++) { Workspace_sptr ws = m_outputWorkspaceProps[i]->getWorkspace(); @@ -408,7 +407,7 @@ namespace Mantid && std::find(m_writeLockedWorkspaces.begin(), m_writeLockedWorkspaces.end(), ws) == m_writeLockedWorkspaces.end()) { // Write-lock it if not already - g_log.debug() << "Write-locking " << ws->getName() << std::endl; + debugLog << "Write-locking " << ws->getName() << std::endl; ws->getLock()->writeLock(); m_writeLockedWorkspaces.push_back(ws); } @@ -427,7 +426,7 @@ namespace Mantid && std::find(m_writeLockedWorkspaces.begin(), m_writeLockedWorkspaces.end(), ws) == m_writeLockedWorkspaces.end()) { // Read-lock it if not already write-locked - g_log.debug() << "Read-locking " << ws->getName() << std::endl; + debugLog << "Read-locking " << ws->getName() << std::endl; ws->getLock()->readLock(); m_readLockedWorkspaces.push_back(ws); } @@ -444,13 +443,13 @@ namespace Mantid // Do not lock workspace for child algos if (this->isChild()) return; - + auto & debugLog = g_log.debug(); for (size_t i=0; i<m_writeLockedWorkspaces.size(); i++) { Workspace_sptr ws = m_writeLockedWorkspaces[i]; if (ws) { - g_log.debug() << "Unlocking " << ws->getName() << std::endl; + debugLog << "Unlocking " << ws->getName() << std::endl; ws->getLock()->unlock(); } } @@ -459,7 +458,7 @@ namespace Mantid Workspace_sptr ws = m_readLockedWorkspaces[i]; if (ws) { - g_log.debug() << "Unlocking " << ws->getName() << std::endl; + debugLog << "Unlocking " << ws->getName() << std::endl; ws->getLock()->unlock(); } } @@ -485,7 +484,7 @@ namespace Mantid { DeprecatedAlgorithm * depo = dynamic_cast<DeprecatedAlgorithm *>(this); if (depo != NULL) - g_log.error(depo->deprecationMsg(this)); + getLogger().error(depo->deprecationMsg(this)); } // Start by freeing up any memory available. Mantid::API::MemoryManager::Instance().releaseFreeMemory(); @@ -496,7 +495,6 @@ namespace Mantid // Return a failure if the algorithm hasn't been initialized if ( !isInitialized() ) { - g_log.error("Algorithm is not initialized:" + this->name()); throw std::runtime_error("Algorithm is not initialised:" + this->name()); } @@ -534,15 +532,17 @@ namespace Mantid { size_t numErrors = errors.size(); // Log each issue + auto & errorLog = getLogger().error(); + auto & warnLog = getLogger().warning(); for (auto it = errors.begin(); it != errors.end(); it++) { if (this->existsProperty(it->first)) - g_log.error() << "Invalid value for " << it->first << ": " << it->second << "\n"; + errorLog << "Invalid value for " << it->first << ": " << it->second << "\n"; else { numErrors -= 1; // don't count it as an error - g_log.warning() << "validateInputs() references non-existant property \"" - << it->first << "\"\n"; + warnLog << "validateInputs() references non-existant property \"" + << it->first << "\"\n"; } } // Throw because something was invalid @@ -568,8 +568,8 @@ namespace Mantid } catch(std::exception& ex) { - g_log.error()<< "Error in execution of algorithm "<< this->name()<<std::endl; - g_log.error()<<ex.what()<<std::endl; + getLogger().error() << "Error in execution of algorithm "<< this->name() << std::endl + << ex.what()<<std::endl; notificationCenter().postNotification(new ErrorNotification(this,ex.what())); m_running = false; if (m_isChildAlgorithm || m_runningAsync || m_rethrow) @@ -626,11 +626,11 @@ namespace Mantid setExecuted(true); if (!m_isChildAlgorithm || m_alwaysStoreInADS) { - g_log.notice() << name() << " successful, Duration " + getLogger().notice() << name() << " successful, Duration " << std::fixed << std::setprecision(2) << duration << " seconds" << std::endl; } else - g_log.debug() << name() << " finished with isChild = " << isChild() << std::endl; + getLogger().debug() << name() << " finished with isChild = " << isChild() << std::endl; m_running = false; } catch(std::runtime_error& ex) @@ -639,8 +639,8 @@ namespace Mantid if (m_isChildAlgorithm || m_runningAsync || m_rethrow) throw; else { - g_log.error()<< "Error in execution of algorithm "<< this->name()<<std::endl; - g_log.error()<< ex.what()<<std::endl; + getLogger().error() << "Error in execution of algorithm "<< this->name()<<std::endl + << ex.what()<<std::endl; } notificationCenter().postNotification(new ErrorNotification(this,ex.what())); m_running = false; @@ -651,8 +651,8 @@ namespace Mantid if (m_isChildAlgorithm || m_runningAsync || m_rethrow) throw; else { - g_log.error()<< "Logic Error in execution of algorithm "<< this->name()<<std::endl; - g_log.error()<< ex.what()<<std::endl; + getLogger().error() << "Logic Error in execution of algorithm "<< this->name() << std::endl + << ex.what()<<std::endl; } notificationCenter().postNotification(new ErrorNotification(this,ex.what())); m_running = false; @@ -662,7 +662,7 @@ namespace Mantid { m_runningAsync = false; m_running = false; - g_log.error() << this->name() << ": Execution terminated by user.\n"; + getLogger().error() << this->name() << ": Execution terminated by user.\n"; notificationCenter().postNotification(new ErrorNotification(this,ex.what())); this->unlockWorkspaces(); throw; @@ -675,8 +675,8 @@ namespace Mantid m_running = false; notificationCenter().postNotification(new ErrorNotification(this,ex.what())); - g_log.error() << "Error in execution of algorithm " << this->name() << ":\n"; - g_log.error(ex.what()); + getLogger().error() << "Error in execution of algorithm " << this->name() << ":\n" + << ex.what() << "\n"; this->unlockWorkspaces(); throw; } @@ -689,7 +689,7 @@ namespace Mantid m_running = false; notificationCenter().postNotification(new ErrorNotification(this,"UNKNOWN Exception is caught in exec()")); - g_log.error() << this->name() << ": UNKNOWN Exception is caught in exec()\n"; + getLogger().error() << this->name() << ": UNKNOWN Exception is caught in exec()\n"; this->unlockWorkspaces(); throw; } @@ -718,13 +718,11 @@ namespace Mantid } catch (std::runtime_error&) { - g_log.error() << "Unable to successfully run ChildAlgorithm " << this->name() << std::endl; throw; } if ( ! executed ) { - g_log.error() << "Unable to successfully run ChildAlgorithm " << this->name() << std::endl; throw std::runtime_error("Unable to successfully run ChildAlgorithm " + this->name()); } } @@ -754,7 +752,6 @@ namespace Mantid } catch (std::runtime_error&) { - g_log.error("Error storing output workspace in AnalysisDataService"); throw; } } @@ -778,7 +775,6 @@ namespace Mantid } catch (std::runtime_error&) { - g_log.error("Error storing output workspace in AnalysisDataService"); throw; } } @@ -813,8 +809,7 @@ namespace Mantid } catch (std::runtime_error& exc) { - g_log.error() << "Unable to initialise Child Algorithm " << name << std::endl; - g_log.error() << exc.what() << "\n"; + throw std::runtime_error("Unable to initialise Child Algorithm '" + name + "'"); } // If output workspaces are nameless, give them a temporary name to satisfy validator @@ -1074,13 +1069,15 @@ namespace Mantid /** Sends out algorithm parameter information to the logger */ void Algorithm::logAlgorithmInfo() const { - g_log.notice() << name() << " started"; + auto & logger = getLogger(); + + logger.notice() << name() << " started"; if (this->isChild()) - g_log.notice() << " (child)"; - g_log.notice() << std::endl; + logger.notice() << " (child)"; + logger.notice() << std::endl; // Make use of the AlgorithmHistory class, which holds all the info we want here AlgorithmHistory AH(this); - g_log.information() << AH; + logger.information() << AH; } diff --git a/Code/Mantid/Framework/API/src/AlgorithmFactory.cpp b/Code/Mantid/Framework/API/src/AlgorithmFactory.cpp index b5d752cbaaf..152a3215f42 100644 --- a/Code/Mantid/Framework/API/src/AlgorithmFactory.cpp +++ b/Code/Mantid/Framework/API/src/AlgorithmFactory.cpp @@ -14,10 +14,14 @@ namespace Mantid { namespace API { + namespace + { + /// static logger instance + Kernel::Logger g_log("AlgorithmFactory"); + } - AlgorithmFactoryImpl::AlgorithmFactoryImpl() : - Kernel::DynamicFactory<Algorithm>(), g_log(Kernel::Logger::get("AlgorithmFactory")), - m_vmap() + AlgorithmFactoryImpl::AlgorithmFactoryImpl() + : Kernel::DynamicFactory<Algorithm>(), m_vmap() { // we need to make sure the library manager has been loaded before we // are constructed so that it is destroyed after us and thus does diff --git a/Code/Mantid/Framework/API/src/AlgorithmManager.cpp b/Code/Mantid/Framework/API/src/AlgorithmManager.cpp index 3c7783f744e..bb61eed4a50 100644 --- a/Code/Mantid/Framework/API/src/AlgorithmManager.cpp +++ b/Code/Mantid/Framework/API/src/AlgorithmManager.cpp @@ -14,9 +14,15 @@ namespace Mantid { namespace API { + namespace + { + /// static logger + Kernel::Logger g_log("AlgorithmManager"); + } + /// Private Constructor for singleton class - AlgorithmManagerImpl::AlgorithmManagerImpl(): g_log(Kernel::Logger::get("AlgorithmManager")),m_managed_algs() + AlgorithmManagerImpl::AlgorithmManagerImpl() : m_managed_algs() { if ( ! Kernel::ConfigService::Instance().getValue("algorithms.retained",m_max_no_algs) || m_max_no_algs < 1 ) { diff --git a/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp b/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp index b1922ed5548..a75396630a3 100644 --- a/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp +++ b/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp @@ -17,9 +17,6 @@ namespace Mantid namespace API { - // Get a reference to the logger - Kernel::Logger& AlgorithmProxy::g_log = Kernel::Logger::get("AlgorithmProxy"); - //---------------------------------------------------------------------- // Public methods //---------------------------------------------------------------------- @@ -34,7 +31,6 @@ namespace Mantid { if (!alg) { - g_log.error("Unable to create a proxy algorithm."); throw std::logic_error("Unable to create a proxy algorithm."); } alg->initialize(); diff --git a/Code/Mantid/Framework/API/src/CatalogFactory.cpp b/Code/Mantid/Framework/API/src/CatalogFactory.cpp index 5259ee6edeb..6aa845f93c7 100644 --- a/Code/Mantid/Framework/API/src/CatalogFactory.cpp +++ b/Code/Mantid/Framework/API/src/CatalogFactory.cpp @@ -1,5 +1,4 @@ #include "MantidAPI/CatalogFactory.h" -#include "MantidKernel/Logger.h" namespace Mantid { @@ -7,7 +6,7 @@ namespace Mantid { /// Constructor CatalogFactoryImpl::CatalogFactoryImpl() : - Kernel::DynamicFactory<ICatalog>(), m_createdCatalogs(), m_log(Kernel::Logger::get("CatalogFactory")) {} + Kernel::DynamicFactory<ICatalog>(), m_createdCatalogs() {} /// Destructor CatalogFactoryImpl::~CatalogFactoryImpl(){} } diff --git a/Code/Mantid/Framework/API/src/Column.cpp b/Code/Mantid/Framework/API/src/Column.cpp index 55152fdfc37..81c7376f60d 100644 --- a/Code/Mantid/Framework/API/src/Column.cpp +++ b/Code/Mantid/Framework/API/src/Column.cpp @@ -1,4 +1,5 @@ #include "MantidAPI/Column.h" +#include "MantidKernel/Logger.h" #include <algorithm> #include <iostream> @@ -7,8 +8,11 @@ namespace Mantid namespace API { -// Get a reference to the logger -Kernel::Logger& Column::g_log = Kernel::Logger::get("Column"); +namespace +{ + /// static logger object + Kernel::Logger g_log("Column"); +} template<> bool Column::isType<bool>()const diff --git a/Code/Mantid/Framework/API/src/ColumnFactory.cpp b/Code/Mantid/Framework/API/src/ColumnFactory.cpp index 23fff01b0de..32ead8e03a4 100644 --- a/Code/Mantid/Framework/API/src/ColumnFactory.cpp +++ b/Code/Mantid/Framework/API/src/ColumnFactory.cpp @@ -2,26 +2,26 @@ #include <sstream> #include "MantidAPI/ColumnFactory.h" #include "MantidAPI/Column.h" -#include "MantidKernel/Logger.h" + namespace Mantid { namespace API { - ColumnFactoryImpl::ColumnFactoryImpl() : Kernel::DynamicFactory<API::Column>(), g_log(Kernel::Logger::get("ColumnFactory")) - { - } + ColumnFactoryImpl::ColumnFactoryImpl() : Kernel::DynamicFactory<API::Column>() + { + } - ColumnFactoryImpl::~ColumnFactoryImpl() - { - } + ColumnFactoryImpl::~ColumnFactoryImpl() + { + } - boost::shared_ptr<Column> ColumnFactoryImpl::create(const std::string& type) const - { - boost::shared_ptr<Column> c = Kernel::DynamicFactory<Column>::create(type); - c->m_type = type; - return c; - } + boost::shared_ptr<Column> ColumnFactoryImpl::create(const std::string& type) const + { + boost::shared_ptr<Column> c = Kernel::DynamicFactory<Column>::create(type); + c->m_type = type; + return c; + } } // namespace API diff --git a/Code/Mantid/Framework/API/src/CompositeFunction.cpp b/Code/Mantid/Framework/API/src/CompositeFunction.cpp index 18ab56cd421..bc10f9f67d3 100644 --- a/Code/Mantid/Framework/API/src/CompositeFunction.cpp +++ b/Code/Mantid/Framework/API/src/CompositeFunction.cpp @@ -32,11 +32,13 @@ To define a composite function inside a composite function enclose the inner one //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- -#include "MantidKernel/Exception.h" #include "MantidAPI/CompositeFunction.h" #include "MantidAPI/ParameterTie.h" #include "MantidAPI/IConstraint.h" #include "MantidAPI/FunctionFactory.h" +#include "MantidKernel/Exception.h" +#include "MantidKernel/Logger.h" + #include <boost/lexical_cast.hpp> #include <boost/shared_array.hpp> @@ -49,6 +51,12 @@ namespace Mantid namespace API { + namespace + { + /// static logger + Kernel::Logger g_log("CompositeFunction"); + } + using std::size_t; DECLARE_FUNCTION(CompositeFunction) diff --git a/Code/Mantid/Framework/API/src/ConstraintFactory.cpp b/Code/Mantid/Framework/API/src/ConstraintFactory.cpp index e12847ea369..119994e0869 100644 --- a/Code/Mantid/Framework/API/src/ConstraintFactory.cpp +++ b/Code/Mantid/Framework/API/src/ConstraintFactory.cpp @@ -1,7 +1,6 @@ #include "MantidAPI/ConstraintFactory.h" #include "MantidAPI/Expression.h" #include "MantidAPI/IConstraint.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/LibraryManager.h" #include <Poco/StringTokenizer.h> @@ -10,13 +9,12 @@ namespace Mantid namespace API { - ConstraintFactoryImpl::ConstraintFactoryImpl() : Kernel::DynamicFactory<IConstraint>(), g_log(Kernel::Logger::get("ConstraintFactory")) + ConstraintFactoryImpl::ConstraintFactoryImpl() : Kernel::DynamicFactory<IConstraint>() { // we need to make sure the library manager has been loaded before we // are constructed so that it is destroyed after us and thus does // not close any loaded DLLs with loaded algorithms in them Mantid::Kernel::LibraryManager::Instance(); - g_log.debug() << "ConstraintFactory created." << std::endl; } ConstraintFactoryImpl::~ConstraintFactoryImpl() diff --git a/Code/Mantid/Framework/API/src/CostFunctionFactory.cpp b/Code/Mantid/Framework/API/src/CostFunctionFactory.cpp index b7b5d21f156..a7acefcb316 100644 --- a/Code/Mantid/Framework/API/src/CostFunctionFactory.cpp +++ b/Code/Mantid/Framework/API/src/CostFunctionFactory.cpp @@ -1,6 +1,5 @@ #include "MantidAPI/CostFunctionFactory.h" #include "MantidAPI/ICostFunction.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/LibraryManager.h" #include <iostream> @@ -9,13 +8,12 @@ namespace Mantid namespace API { - CostFunctionFactoryImpl::CostFunctionFactoryImpl() : Kernel::DynamicFactory<ICostFunction>(), g_log(Kernel::Logger::get("CostFunctionFactory")) + CostFunctionFactoryImpl::CostFunctionFactoryImpl() : Kernel::DynamicFactory<ICostFunction>() { // we need to make sure the library manager has been loaded before we // are constructed so that it is destroyed after us and thus does // not close any loaded DLLs with loaded algorithms in them Mantid::Kernel::LibraryManager::Instance(); - g_log.debug() << "CostFunctionFactory created." << std::endl; } } // namespace API diff --git a/Code/Mantid/Framework/API/src/DataProcessorAlgorithm.cpp b/Code/Mantid/Framework/API/src/DataProcessorAlgorithm.cpp index dbb8c4ce057..e91516e0826 100644 --- a/Code/Mantid/Framework/API/src/DataProcessorAlgorithm.cpp +++ b/Code/Mantid/Framework/API/src/DataProcessorAlgorithm.cpp @@ -234,7 +234,7 @@ namespace API } else { - g_log.notice() << "Could not find property manager" << std::endl; + getLogger().notice() << "Could not find property manager" << std::endl; processProperties = boost::make_shared<PropertyManager>(); PropertyManagerDataService::Instance().addOrReplace(propertyManager, processProperties); } diff --git a/Code/Mantid/Framework/API/src/ExperimentInfo.cpp b/Code/Mantid/Framework/API/src/ExperimentInfo.cpp index 6a33fa9e5da..e5b056cbe02 100644 --- a/Code/Mantid/Framework/API/src/ExperimentInfo.cpp +++ b/Code/Mantid/Framework/API/src/ExperimentInfo.cpp @@ -36,8 +36,11 @@ namespace Mantid { namespace API { - - Kernel::Logger& ExperimentInfo::g_log = Kernel::Logger::get("ExperimentInfo"); + namespace + { + /// static logger object + Kernel::Logger g_log("ExperimentInfo"); + } //---------------------------------------------------------------------------------------------- /** Constructor diff --git a/Code/Mantid/Framework/API/src/FileFinder.cpp b/Code/Mantid/Framework/API/src/FileFinder.cpp index f2653845f25..5d46edb8ac5 100644 --- a/Code/Mantid/Framework/API/src/FileFinder.cpp +++ b/Code/Mantid/Framework/API/src/FileFinder.cpp @@ -26,6 +26,9 @@ namespace { + /// static logger object + Mantid::Kernel::Logger g_log("FileFinder"); + /** * Unary predicate for use with remove_if. Checks for the existance of * a "*" wild card in the file extension string passed to it. @@ -56,7 +59,7 @@ namespace Mantid /** * Default constructor */ - FileFinderImpl::FileFinderImpl() : g_log(Mantid::Kernel::Logger::get("FileFinderImpl")) + FileFinderImpl::FileFinderImpl() { // Make sure plugins are loaded std::string libpath = Kernel::ConfigService::Instance().getString("plugins.directory"); diff --git a/Code/Mantid/Framework/API/src/FileLoaderRegistry.cpp b/Code/Mantid/Framework/API/src/FileLoaderRegistry.cpp index a94e14a42e5..6edc818909d 100644 --- a/Code/Mantid/Framework/API/src/FileLoaderRegistry.cpp +++ b/Code/Mantid/Framework/API/src/FileLoaderRegistry.cpp @@ -166,7 +166,7 @@ namespace Mantid */ FileLoaderRegistryImpl::FileLoaderRegistryImpl() : m_names(2, std::multimap<std::string,int>()), m_totalSize(0), - m_log(Kernel::Logger::get("FileLoaderRegistry")) + m_log("FileLoaderRegistry") { } diff --git a/Code/Mantid/Framework/API/src/FrameworkManager.cpp b/Code/Mantid/Framework/API/src/FrameworkManager.cpp index 71c02c39b83..2940b025914 100644 --- a/Code/Mantid/Framework/API/src/FrameworkManager.cpp +++ b/Code/Mantid/Framework/API/src/FrameworkManager.cpp @@ -26,6 +26,11 @@ namespace Mantid { namespace API { + namespace + { + /// static logger + Kernel::Logger g_log("FrameworkManager"); + } /** This is a function called every time NeXuS raises an error. * This swallows the errors and outputs nothing. @@ -42,9 +47,9 @@ namespace API /// Default constructor -FrameworkManagerImpl::FrameworkManagerImpl() : g_log(Kernel::Logger::get("FrameworkManager")) +FrameworkManagerImpl::FrameworkManagerImpl() #ifdef MPI_BUILD - , m_mpi_environment() + m_mpi_environment() #endif { // Mantid only understands English... @@ -108,7 +113,7 @@ void FrameworkManagerImpl::loadAllPlugins() } else { - this->g_log.debug("Cannot load ParaView libraries"); + g_log.debug("Cannot load ParaView libraries"); } } @@ -122,12 +127,12 @@ void FrameworkManagerImpl::loadPluginsUsingKey(const std::string & key) std::string pluginDir = config.getString(key); if (pluginDir.length() > 0) { - this->g_log.debug("Loading libraries from \"" + pluginDir + "\""); + g_log.debug("Loading libraries from \"" + pluginDir + "\""); Kernel::LibraryManager::Instance().OpenAllLibraries(pluginDir, false); } else { - this->g_log.debug("No library directory found in key \"" + key + "\""); + g_log.debug("No library directory found in key \"" + key + "\""); } } diff --git a/Code/Mantid/Framework/API/src/FuncMinimizerFactory.cpp b/Code/Mantid/Framework/API/src/FuncMinimizerFactory.cpp index c6cdd35d6e6..b8f38072f8b 100644 --- a/Code/Mantid/Framework/API/src/FuncMinimizerFactory.cpp +++ b/Code/Mantid/Framework/API/src/FuncMinimizerFactory.cpp @@ -1,7 +1,6 @@ #include "MantidAPI/FuncMinimizerFactory.h" #include "MantidAPI/IFuncMinimizer.h" #include "MantidAPI/Expression.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/LibraryManager.h" #include <stdexcept> @@ -11,13 +10,12 @@ namespace Mantid namespace API { -FuncMinimizerFactoryImpl::FuncMinimizerFactoryImpl() : Kernel::DynamicFactory<IFuncMinimizer>(), g_log(Kernel::Logger::get("FuncMinimizerFactory")) +FuncMinimizerFactoryImpl::FuncMinimizerFactoryImpl() : Kernel::DynamicFactory<IFuncMinimizer>() { // we need to make sure the library manager has been loaded before we // are constructed so that it is destroyed after us and thus does // not close any loaded DLLs with loaded algorithms in them Mantid::Kernel::LibraryManager::Instance(); - g_log.debug() << "FuncMinimizerFactory created." << std::endl; } /** @@ -42,7 +40,6 @@ boost::shared_ptr<IFuncMinimizer> FuncMinimizerFactoryImpl::createMinimizer(cons if ( n == 0 ) { std::string mess = "Found empty initialization string"; - g_log.error(mess); throw std::invalid_argument(mess); } diff --git a/Code/Mantid/Framework/API/src/FunctionFactory.cpp b/Code/Mantid/Framework/API/src/FunctionFactory.cpp index 0b81cca608f..bfb9b1163ce 100644 --- a/Code/Mantid/Framework/API/src/FunctionFactory.cpp +++ b/Code/Mantid/Framework/API/src/FunctionFactory.cpp @@ -7,7 +7,6 @@ #include "MantidAPI/IConstraint.h" #include "MantidAPI/Workspace.h" #include "MantidAPI/AnalysisDataService.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/LibraryManager.h" #include <Poco/StringTokenizer.h> #include <sstream> @@ -17,13 +16,12 @@ namespace Mantid namespace API { - FunctionFactoryImpl::FunctionFactoryImpl() : Kernel::DynamicFactory<IFunction>(), g_log(Kernel::Logger::get("FunctionFactory")) + FunctionFactoryImpl::FunctionFactoryImpl() : Kernel::DynamicFactory<IFunction>() { // we need to make sure the library manager has been loaded before we // are constructed so that it is destroyed after us and thus does // not close any loaded DLLs with loaded algorithms in them Mantid::Kernel::LibraryManager::Instance(); - g_log.debug() << "FunctionFactory created." << std::endl; } FunctionFactoryImpl::~FunctionFactoryImpl() diff --git a/Code/Mantid/Framework/API/src/FunctionProperty.cpp b/Code/Mantid/Framework/API/src/FunctionProperty.cpp index 339c391b001..0af49aabfe2 100644 --- a/Code/Mantid/Framework/API/src/FunctionProperty.cpp +++ b/Code/Mantid/Framework/API/src/FunctionProperty.cpp @@ -6,8 +6,6 @@ namespace Mantid { namespace API { - Kernel::Logger& FunctionProperty::g_log = Kernel::Logger::get("FunctionProperty"); - /** Constructor. * Sets the property names but initialises the function pointer to null. * @param name :: The name to assign to the property diff --git a/Code/Mantid/Framework/API/src/GridDomain.cpp b/Code/Mantid/Framework/API/src/GridDomain.cpp index 7ab4e939599..2b3869ec48d 100644 --- a/Code/Mantid/Framework/API/src/GridDomain.cpp +++ b/Code/Mantid/Framework/API/src/GridDomain.cpp @@ -6,13 +6,17 @@ #include <stdexcept> #include "MantidAPI/GridDomain.h" +#include "MantidKernel/Logger.h" namespace Mantid { namespace API { - -Kernel::Logger& GridDomain::g_log = Kernel::Logger::get("GridDomain"); + namespace + { + /// static logger + Kernel::Logger g_log("GridDomain"); + } /// number of points in the grid size_t GridDomain::size() const{ @@ -45,7 +49,6 @@ GridDomain_sptr GridDomain::getGrid(size_t index) catch(std::out_of_range &ex) { g_log.error( ex.what() ); - } return g; } diff --git a/Code/Mantid/Framework/API/src/IFunction.cpp b/Code/Mantid/Framework/API/src/IFunction.cpp index a4b30f9435f..b3757ed8436 100644 --- a/Code/Mantid/Framework/API/src/IFunction.cpp +++ b/Code/Mantid/Framework/API/src/IFunction.cpp @@ -35,10 +35,14 @@ namespace Mantid { namespace API { - using namespace Geometry; - Kernel::Logger& IFunction::g_log = Kernel::Logger::get("IFunction"); + namespace + { + /// static logger + Kernel::Logger g_log("IFunction"); + } + /** * Destructor diff --git a/Code/Mantid/Framework/API/src/IFunction1D.cpp b/Code/Mantid/Framework/API/src/IFunction1D.cpp index 311b3446c91..0d6b46dd481 100644 --- a/Code/Mantid/Framework/API/src/IFunction1D.cpp +++ b/Code/Mantid/Framework/API/src/IFunction1D.cpp @@ -30,7 +30,6 @@ namespace Mantid namespace API { using namespace Geometry; - Kernel::Logger& IFunction1D::g_log = Kernel::Logger::get("IFunction1D"); void IFunction1D::function(const FunctionDomain& domain, FunctionValues& values) const { diff --git a/Code/Mantid/Framework/API/src/IFunctionMD.cpp b/Code/Mantid/Framework/API/src/IFunctionMD.cpp index 44d7820ea06..55e475534cd 100644 --- a/Code/Mantid/Framework/API/src/IFunctionMD.cpp +++ b/Code/Mantid/Framework/API/src/IFunctionMD.cpp @@ -8,7 +8,6 @@ #include "MantidAPI/IMDIterator.h" #include "MantidAPI/IConstraint.h" #include "MantidAPI/FunctionDomainMD.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/Exception.h" #include "MantidGeometry/muParser_Silent.h" @@ -28,8 +27,6 @@ namespace API { using namespace Geometry; - Kernel::Logger& IFunctionMD::g_log = Kernel::Logger::get("IFunctionMD"); - /// Virtual copy constructor boost::shared_ptr<IFunction> IFunctionMD::clone() const { @@ -71,7 +68,6 @@ namespace API } catch(std::exception& e) { - g_log.error() << "IFunctionMD::setWorkspace failed with error: " << e.what() << '\n'; throw; } diff --git a/Code/Mantid/Framework/API/src/IFunctionMW.cpp b/Code/Mantid/Framework/API/src/IFunctionMW.cpp index 9893d9a4877..b174c3427f1 100644 --- a/Code/Mantid/Framework/API/src/IFunctionMW.cpp +++ b/Code/Mantid/Framework/API/src/IFunctionMW.cpp @@ -11,8 +11,6 @@ namespace API { using namespace Geometry; - Kernel::Logger& IFunctionMW::g_log = Kernel::Logger::get("IFunctionMW"); - /** Initialize the function providing it the workspace * @param workspace :: The workspace to set * @param wi :: The workspace index diff --git a/Code/Mantid/Framework/API/src/IPowderDiffPeakFunction.cpp b/Code/Mantid/Framework/API/src/IPowderDiffPeakFunction.cpp index 1bdacae671f..aa65b994a37 100644 --- a/Code/Mantid/Framework/API/src/IPowderDiffPeakFunction.cpp +++ b/Code/Mantid/Framework/API/src/IPowderDiffPeakFunction.cpp @@ -175,7 +175,6 @@ namespace API // Throw exception if tried to reset the miller index stringstream errss; errss << "Profile function " << name() << "cannot have (HKL) reset."; - g_log.error(errss.str()); throw runtime_error(errss.str()); } else @@ -194,7 +193,6 @@ namespace API { stringstream errmsg; errmsg << "H = K = L = 0 is not allowed"; - g_log.error(errmsg.str()); throw std::invalid_argument(errmsg.str()); } diff --git a/Code/Mantid/Framework/API/src/ITableWorkspace.cpp b/Code/Mantid/Framework/API/src/ITableWorkspace.cpp index 1133c5b67fd..738a338a666 100644 --- a/Code/Mantid/Framework/API/src/ITableWorkspace.cpp +++ b/Code/Mantid/Framework/API/src/ITableWorkspace.cpp @@ -1,6 +1,5 @@ #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/AnalysisDataService.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/IPropertyManager.h" namespace Mantid @@ -8,9 +7,6 @@ namespace Mantid namespace API { -// Get a reference to the logger -Kernel::Logger& ITableWorkspace::g_log = Kernel::Logger::get("ITableWorkspace"); - /** */ const std::string ITableWorkspace::toString() const diff --git a/Code/Mantid/Framework/API/src/ITransformScale.cpp b/Code/Mantid/Framework/API/src/ITransformScale.cpp deleted file mode 100644 index 4c93b46e6af..00000000000 --- a/Code/Mantid/Framework/API/src/ITransformScale.cpp +++ /dev/null @@ -1,14 +0,0 @@ -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- - -#include "MantidAPI/ITransformScale.h" - -namespace Mantid -{ -namespace API -{ -Kernel::Logger& ITransformScale::g_log = Kernel::Logger::get("ITransformScale"); - -} // namespace API -} // namespace Mantid diff --git a/Code/Mantid/Framework/API/src/LiveListenerFactory.cpp b/Code/Mantid/Framework/API/src/LiveListenerFactory.cpp index 33bbe3512ca..130ab94aa9c 100644 --- a/Code/Mantid/Framework/API/src/LiveListenerFactory.cpp +++ b/Code/Mantid/Framework/API/src/LiveListenerFactory.cpp @@ -10,9 +10,13 @@ namespace Mantid { namespace API { + namespace + { + /// static logger + Kernel::Logger g_log("LiveListenerFactory"); + } - LiveListenerFactoryImpl::LiveListenerFactoryImpl() : Kernel::DynamicFactory<ILiveListener>(), - m_log(Kernel::Logger::get("LiveListenerFactory")) + LiveListenerFactoryImpl::LiveListenerFactoryImpl() : Kernel::DynamicFactory<ILiveListener>() { } @@ -41,7 +45,7 @@ namespace API // If we can't connect, log and throw an exception std::stringstream ss; ss << "Unable to connect listener " << listener->name() << " to " << inst.liveDataAddress(); - m_log.debug(ss.str()); + g_log.debug(ss.str()); throw std::runtime_error(ss.str()); } } catch ( Kernel::Exception::NotFoundError& ) @@ -60,7 +64,7 @@ namespace API { std::stringstream ss; ss << "Unable to connect listener " << listener->name() << " to " << instrumentName << ": " << pocoEx.what(); - m_log.debug(ss.str()); + g_log.debug(ss.str()); throw std::runtime_error(ss.str()); } diff --git a/Code/Mantid/Framework/API/src/LogManager.cpp b/Code/Mantid/Framework/API/src/LogManager.cpp index 7bd9a55bac8..8f9f9c99af8 100644 --- a/Code/Mantid/Framework/API/src/LogManager.cpp +++ b/Code/Mantid/Framework/API/src/LogManager.cpp @@ -21,8 +21,11 @@ namespace API using namespace Kernel; -// Get a reference to the logger -Kernel::Logger& LogManager::g_log = Kernel::Logger::get("LogManager"); + namespace + { + /// static logger + Logger g_log("LogManager"); + } /// Name of the log entry containing the proton charge when retrieved using getProtonCharge const char * LogManager::PROTON_CHARGE_LOG_NAME = "gd_prtn_chrg"; diff --git a/Code/Mantid/Framework/API/src/LogarithmScale.cpp b/Code/Mantid/Framework/API/src/LogarithmScale.cpp index 2d58eb320f0..e5e78c43e60 100644 --- a/Code/Mantid/Framework/API/src/LogarithmScale.cpp +++ b/Code/Mantid/Framework/API/src/LogarithmScale.cpp @@ -7,11 +7,18 @@ #include "MantidAPI/LogarithmScale.h" #include "MantidAPI/TransformScaleFactory.h" +#include "MantidKernel/Logger.h" namespace Mantid { namespace API { + namespace + { + /// static logger + Kernel::Logger g_log("LogarithmScale"); + } + DECLARE_TRANSFORMSCALE(LogarithmScale); diff --git a/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp b/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp index e05545273ce..601c7f9f843 100644 --- a/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp +++ b/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp @@ -25,7 +25,12 @@ namespace Mantid using namespace Geometry; using Kernel::V3D; - Kernel::Logger& MatrixWorkspace::g_log = Kernel::Logger::get("MatrixWorkspace"); + namespace + { + /// static logger + Kernel::Logger g_log("MatrixWorkspace"); + } + const std::string MatrixWorkspace::xDimensionId = "xDimension"; const std::string MatrixWorkspace::yDimensionId = "yDimension"; @@ -91,7 +96,6 @@ namespace Mantid // Check validity of arguments if (NVectors == 0 || XLength == 0 || YLength == 0) { - g_log.error("All arguments to init must be positive and non-zero"); throw std::out_of_range("All arguments to init must be positive and non-zero"); } @@ -105,7 +109,6 @@ namespace Mantid } catch(std::runtime_error& ex) { - g_log.error() << "Error initializing the workspace" << ex.what() << std::endl; throw; } @@ -205,10 +208,9 @@ namespace Mantid m_nearestNeighbours.reset(); } - catch (std::runtime_error & e) + catch (std::runtime_error &) { - g_log.error() << "MatrixWorkspace::rebuildSpectraMapping() error:" << std::endl; - throw &e; + throw; } } @@ -849,7 +851,6 @@ namespace Mantid { if ( axisIndex >= m_axes.size() ) { - g_log.error() << "Argument to getAxis (" << axisIndex << ") is invalid for this (" << m_axes.size() << " axis) workspace" << std::endl; throw Kernel::Exception::IndexError(axisIndex, m_axes.size(),"Argument to getAxis is invalid for this workspace"); } @@ -867,7 +868,6 @@ namespace Mantid // First check that axisIndex is in range if ( axisIndex >= m_axes.size() ) { - g_log.error() << "Value of axisIndex (" << axisIndex << ") is invalid for this (" << m_axes.size() << " axis) workspace" << std::endl; throw Kernel::Exception::IndexError(axisIndex, m_axes.size(),"Value of axisIndex is invalid for this workspace"); } // If we're OK, then delete the old axis and set the pointer to the new one @@ -1052,7 +1052,6 @@ namespace Mantid // Throw if there are no masked bins for this spectrum. The caller should check first using hasMaskedBins! if (it==m_masks.end()) { - g_log.error() << "There are no masked bins for spectrum index " << workspaceIndex << std::endl; throw Kernel::Exception::IndexError(workspaceIndex,0,"MatrixWorkspace::maskedBins"); } diff --git a/Code/Mantid/Framework/API/src/MemoryManager.cpp b/Code/Mantid/Framework/API/src/MemoryManager.cpp index 5e0a23eb368..fb3b3fd9cd9 100644 --- a/Code/Mantid/Framework/API/src/MemoryManager.cpp +++ b/Code/Mantid/Framework/API/src/MemoryManager.cpp @@ -3,6 +3,7 @@ //---------------------------------------------------------------------- #include "MantidAPI/MemoryManager.h" #include "MantidKernel/ConfigService.h" +#include "MantidKernel/Logger.h" #include "MantidKernel/Memory.h" #ifdef USE_TCMALLOC @@ -17,10 +18,14 @@ namespace Mantid { namespace API { + namespace + { + /// static logger + Kernel::Logger g_log("MemoryManager"); + } /// Private Constructor for singleton class MemoryManagerImpl::MemoryManagerImpl() : - g_log(Kernel::Logger::get("MemoryManager")), memoryCleared(0) { g_log.debug() << "Memory Manager created." << std::endl; diff --git a/Code/Mantid/Framework/API/src/MultiPeriodGroupAlgorithm.cpp b/Code/Mantid/Framework/API/src/MultiPeriodGroupAlgorithm.cpp index a6df61b8aea..1508a168520 100644 --- a/Code/Mantid/Framework/API/src/MultiPeriodGroupAlgorithm.cpp +++ b/Code/Mantid/Framework/API/src/MultiPeriodGroupAlgorithm.cpp @@ -248,7 +248,6 @@ namespace Mantid IAlgorithm* alg = alg_sptr.get(); if(!alg) { - g_log.error()<<"CreateAlgorithm failed for "<<this->name()<<"("<<this->version()<<")"<<std::endl; throw std::runtime_error("Algorithm creation failed."); } alg->initialize(); diff --git a/Code/Mantid/Framework/API/src/MultipleFileProperty.cpp b/Code/Mantid/Framework/API/src/MultipleFileProperty.cpp index 31ff72271d7..3a3e723e382 100644 --- a/Code/Mantid/Framework/API/src/MultipleFileProperty.cpp +++ b/Code/Mantid/Framework/API/src/MultipleFileProperty.cpp @@ -21,6 +21,9 @@ using namespace Mantid::API; namespace // anonymous { + /// static logger + Mantid::Kernel::Logger g_log("MultipleFileProperty"); + /** * Unary predicate for use with copy_if. Checks for the existance of * a "*" wild card in the file extension string passed to it. @@ -49,8 +52,7 @@ namespace API m_multiFileLoadingEnabled(), m_exts(), m_parser(), - m_defaultExt(""), - g_log(Kernel::Logger::get("MultipleFileProperty")) + m_defaultExt("") { std::string allowMultiFileLoading = Kernel::ConfigService::Instance().getString("loading.multifile"); diff --git a/Code/Mantid/Framework/API/src/ParamFunction.cpp b/Code/Mantid/Framework/API/src/ParamFunction.cpp index f2793e5ae89..42b8bc3a2b9 100644 --- a/Code/Mantid/Framework/API/src/ParamFunction.cpp +++ b/Code/Mantid/Framework/API/src/ParamFunction.cpp @@ -2,6 +2,7 @@ // Includes //---------------------------------------------------------------------- #include "MantidKernel/Exception.h" +#include "MantidKernel/Logger.h" #include "MantidAPI/ParamFunction.h" #include "MantidAPI/IConstraint.h" #include "MantidAPI/ParameterTie.h" @@ -17,6 +18,11 @@ namespace Mantid { namespace API { + namespace + { + Kernel::Logger g_log("ParamFunction"); + } + /// Destructor ParamFunction::~ParamFunction() diff --git a/Code/Mantid/Framework/API/src/Run.cpp b/Code/Mantid/Framework/API/src/Run.cpp index bb98b5b83f1..0eb5b21265f 100644 --- a/Code/Mantid/Framework/API/src/Run.cpp +++ b/Code/Mantid/Framework/API/src/Run.cpp @@ -35,9 +35,11 @@ namespace const char * PEAK_RADIUS_GROUP = "peak_radius"; const char * INNER_BKG_RADIUS_GROUP = "inner_bkg_radius"; const char * OUTER_BKG_RADIUS_GROUP = "outer_bkg_radius"; + + /// static logger object + Kernel::Logger g_log("Run"); + } -// Get a reference to the logger -Kernel::Logger& Run::g_log = Kernel::Logger::get("Run"); //---------------------------------------------------------------------- // Public member functions @@ -212,7 +214,6 @@ Kernel::Logger& Run::g_log = Kernel::Logger::get("Run"); } catch (Exception::NotFoundError &) { - //g_log.information() << "proton_charge log value not found. Total proton charge set to 0.0\n"; this->setProtonCharge(0); return 0; } diff --git a/Code/Mantid/Framework/API/src/ScriptRepositoryFactory.cpp b/Code/Mantid/Framework/API/src/ScriptRepositoryFactory.cpp index 48d36a81306..2df6808fc39 100644 --- a/Code/Mantid/Framework/API/src/ScriptRepositoryFactory.cpp +++ b/Code/Mantid/Framework/API/src/ScriptRepositoryFactory.cpp @@ -1,6 +1,5 @@ #include "MantidAPI/ScriptRepositoryFactory.h" #include "MantidAPI/ScriptRepository.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/LibraryManager.h" #include <Poco/StringTokenizer.h> #include <sstream> @@ -10,13 +9,12 @@ namespace Mantid namespace API { - ScriptRepositoryFactoryImpl::ScriptRepositoryFactoryImpl() : Kernel::DynamicFactory<ScriptRepository>(), g_log(Kernel::Logger::get("ScriptRepositoryFactory")) + ScriptRepositoryFactoryImpl::ScriptRepositoryFactoryImpl() : Kernel::DynamicFactory<ScriptRepository>() { // we need to make sure the library manager has been loaded before we // are constructed so that it is destroyed after us and thus does // not close any loaded DLLs with loaded algorithms in them Mantid::Kernel::LibraryManager::Instance(); - g_log.debug() << "ScriptRepositoryFactory created." << std::endl; } ScriptRepositoryFactoryImpl::~ScriptRepositoryFactoryImpl() diff --git a/Code/Mantid/Framework/API/src/TableRow.cpp b/Code/Mantid/Framework/API/src/TableRow.cpp index 42edeb4d48e..43520ae955b 100644 --- a/Code/Mantid/Framework/API/src/TableRow.cpp +++ b/Code/Mantid/Framework/API/src/TableRow.cpp @@ -6,9 +6,6 @@ namespace Mantid namespace API { -// Get a reference to the logger -Kernel::Logger& TableRow::g_log = Kernel::Logger::get("TableRow"); - /** Constructor @param trh :: TableRowHelper returned by TableWorkspace::getRow */ @@ -33,7 +30,6 @@ void TableRow::row(size_t i) } else { - g_log.error("Row index out of range."); throw std::range_error("Row index out of range."); } } diff --git a/Code/Mantid/Framework/API/src/TransformScaleFactory.cpp b/Code/Mantid/Framework/API/src/TransformScaleFactory.cpp index 809a9d77e52..eb6e5adf9a1 100644 --- a/Code/Mantid/Framework/API/src/TransformScaleFactory.cpp +++ b/Code/Mantid/Framework/API/src/TransformScaleFactory.cpp @@ -1,7 +1,6 @@ #include "MantidAPI/TransformScaleFactory.h" #include "MantidAPI/ITransformScale.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/ConfigService.h" using boost::shared_ptr; @@ -10,9 +9,13 @@ namespace Mantid { namespace API { + namespace + { + /// static logger + Kernel::Logger g_log("TransformScaleFactory"); + } - TransformScaleFactoryImpl::TransformScaleFactoryImpl() : Kernel::DynamicFactory<ITransformScale>(), - g_log(Kernel::Logger::get("TransformScaleFactory")) + TransformScaleFactoryImpl::TransformScaleFactoryImpl() : Kernel::DynamicFactory<ITransformScale>() { } diff --git a/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp b/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp index e794f8b0f9e..581d1e8bb81 100644 --- a/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp +++ b/Code/Mantid/Framework/API/src/WorkspaceFactory.cpp @@ -16,12 +16,17 @@ namespace Mantid { namespace API { + namespace + { + /// static logger object + Kernel::Logger g_log("WorkspaceFactory"); + } using std::size_t; /// Private constructor for singleton class WorkspaceFactoryImpl::WorkspaceFactoryImpl() : - Mantid::Kernel::DynamicFactory<Workspace>(), g_log(Kernel::Logger::get("WorkspaceFactory")) + Mantid::Kernel::DynamicFactory<Workspace>() { g_log.debug() << "WorkspaceFactory created." << std::endl; } @@ -32,7 +37,6 @@ WorkspaceFactoryImpl::WorkspaceFactoryImpl() : */ WorkspaceFactoryImpl::~WorkspaceFactoryImpl() { - // g_log.debug() << "WorkspaceFactory destroyed." << std::endl; } /** Create a new instance of the same type of workspace as that given as argument. @@ -180,7 +184,6 @@ MatrixWorkspace_sptr WorkspaceFactoryImpl::create(const std::string& className, MemoryInfo mi = MemoryManager::Instance().getMemoryInfo(); if ( static_cast<unsigned int>(blockMemory)*100/1024 > mi.availMemory ) { - g_log.error("There is not enough memory to allocate the workspace"); throw std::runtime_error("There is not enough memory to allocate the workspace"); } @@ -222,13 +225,11 @@ ITableWorkspace_sptr WorkspaceFactoryImpl::createTable(const std::string& classN ws = boost::dynamic_pointer_cast<ITableWorkspace>(this->create(className)); if (!ws) { - g_log.error("Class "+className+" cannot be cast to ITableWorkspace"); throw std::runtime_error("Class "+className+" cannot be cast to ITableWorkspace"); } } catch(Kernel::Exception::NotFoundError& e) { - g_log.error(e.what()); throw; } return ws; @@ -243,13 +244,11 @@ IPeaksWorkspace_sptr WorkspaceFactoryImpl::createPeaks(const std::string& classN ws = boost::dynamic_pointer_cast<IPeaksWorkspace>(this->create(className)); if (!ws) { - //g_log.error("Class "+className+" cannot be cast to IPeaksWorkspace"); throw std::runtime_error("Class "+className+" cannot be cast to IPeaksWorkspace"); } } catch(Kernel::Exception::NotFoundError& e) { - g_log.error(e.what()); throw; } return ws; diff --git a/Code/Mantid/Framework/API/src/WorkspaceGroup.cpp b/Code/Mantid/Framework/API/src/WorkspaceGroup.cpp index b53de355f40..7993cae37d7 100644 --- a/Code/Mantid/Framework/API/src/WorkspaceGroup.cpp +++ b/Code/Mantid/Framework/API/src/WorkspaceGroup.cpp @@ -13,9 +13,13 @@ namespace Mantid { namespace API { - -Kernel::Logger& WorkspaceGroup::g_log = Kernel::Logger::get("WorkspaceGroup"); -size_t WorkspaceGroup::g_maximum_depth = 100; + namespace + { + /// initialize depth parameter + size_t MAXIMUM_DEPTH = 100; + /// static logger object + Kernel::Logger g_log("WorkspaceGroup"); + } WorkspaceGroup::WorkspaceGroup() : Workspace(), @@ -393,7 +397,7 @@ bool WorkspaceGroup::isMultiperiod() const bool WorkspaceGroup::isInGroup(const Workspace &workspace, size_t level) const { // Check for a cycle. - if ( level > g_maximum_depth ) + if ( level > MAXIMUM_DEPTH ) { throw std::runtime_error("WorkspaceGroup nesting level is too deep."); } diff --git a/Code/Mantid/Framework/API/src/WorkspaceHistory.cpp b/Code/Mantid/Framework/API/src/WorkspaceHistory.cpp index 209bcb14066..67a9c738d3e 100644 --- a/Code/Mantid/Framework/API/src/WorkspaceHistory.cpp +++ b/Code/Mantid/Framework/API/src/WorkspaceHistory.cpp @@ -16,10 +16,14 @@ namespace Mantid { namespace API { + namespace + { + /// static logger object + Kernel::Logger g_log("WorkspaceHistory"); + } ///Default Constructor -WorkspaceHistory::WorkspaceHistory() : m_environment(), m_algorithms(), - g_log(Kernel::Logger::get("WorkspaceHistory")) +WorkspaceHistory::WorkspaceHistory() : m_environment(), m_algorithms() {} /// Destructor @@ -31,8 +35,7 @@ WorkspaceHistory::~WorkspaceHistory() @param A :: WorkspaceHistory Item to copy */ WorkspaceHistory::WorkspaceHistory(const WorkspaceHistory& A) : - m_environment(A.m_environment), m_algorithms(A.m_algorithms), - g_log(Kernel::Logger::get("WorkspaceHistory")) + m_environment(A.m_environment), m_algorithms(A.m_algorithms) {} /// Returns a const reference to the algorithmHistory -- GitLab