OpenMS  2.8.0
LogConfigHandler.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg$
32 // $Authors: Stephan Aiche$
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 
42 
43 namespace OpenMS
44 {
45 
52  class OPENMS_DLLAPI LogConfigHandler
53  {
54 public:
55 
56  static String PARAM_NAME;
57 
82  Param parse(const StringList & setting);
83 
108  void configure(const Param & param);
109 
117  std::ostream & getStream(const String & stream_name);
118 
123 
125  virtual ~LogConfigHandler();
126 
127 protected:
128 
139 
147  std::set<String> & getConfigSetByName_(const String & stream_type);
148 
159 
160  std::set<String> debug_streams_;
161  std::set<String> info_streams_;
162  std::set<String> warn_streams_;
163  std::set<String> error_streams_;
164  std::set<String> fatal_streams_;
165 
166  std::map<String, StreamHandler::StreamType> stream_type_map_;
167 
168 private:
169  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, LogConfigHandler const & lch);
170 
171  // the pointer to the single instance
173 
174  // it is a singleton so we hide all c' and d'tors
175 
178 
181 
183  virtual LogConfigHandler & operator=(const LogConfigHandler & source);
184  };
185 
187  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, LogConfigHandler const & lch);
188 
189 } // end namespace OpenMS
190 
The LogConfigHandler provides the functionality to configure the internal logging of OpenMS algorithm...
Definition: LogConfigHandler.h:53
static LogConfigHandler * instance_
Definition: LogConfigHandler.h:172
std::ostream & getStream(const String &stream_name)
Returns a reference to the registered stream with the name stream_name.
LogConfigHandler()
Default constructor.
LogConfigHandler(const LogConfigHandler &source)
Copy constructor.
static LogConfigHandler & getInstance()
Returns the instance of LogConfigHandler.
std::set< String > & getConfigSetByName_(const String &stream_type)
Returns the correct set of registered streams for the given stream type (e.g. DEBUG,...
virtual ~LogConfigHandler()
Destructor.
std::set< String > error_streams_
List of all streams that were appended to OpenMS::OpenMS_Log_error.
Definition: LogConfigHandler.h:163
StreamHandler::StreamType getStreamTypeByName_(const String &stream_type)
Translates the given stream_type String into a valid StreamHandler::StreamType.
std::set< String > info_streams_
List of all streams that were appended to OpenMS::OpenMS_Log_info.
Definition: LogConfigHandler.h:161
static String PARAM_NAME
Name of the parameter in which the configuration should be stored.
Definition: LogConfigHandler.h:56
std::set< String > fatal_streams_
List of all streams that were appended to OpenMS::OpenMS_Log_fatal.
Definition: LogConfigHandler.h:164
std::map< String, StreamHandler::StreamType > stream_type_map_
Maps the registered streams to a StreamHandler::StreamType.
Definition: LogConfigHandler.h:166
Param parse(const StringList &setting)
Translates the given list of parameter settings into a LogStream configuration.
virtual LogConfigHandler & operator=(const LogConfigHandler &source)
Assignment operator.
std::set< String > debug_streams_
List of all streams that were appended to OpenMS::OpenMS_Log_debug.
Definition: LogConfigHandler.h:160
friend std::ostream & operator<<(std::ostream &os, LogConfigHandler const &lch)
Overload for the insertion operator (operator<<) to have a formatted output of the LogConfigHandler.
void configure(const Param &param)
Applies the given parameters (param) to the current configuration.
Logger::LogStream & getLogStreamByName_(const String &stream_name)
Returns the named global instance of the LogStream. (OpenMS::OpenMS_Log_debug, OpenMS::OpenMS_Log_inf...
std::set< String > warn_streams_
List of all streams that were appended to OpenMS::OpenMS_Log_warn.
Definition: LogConfigHandler.h:162
Log Stream Class.
Definition: LogStream.h:313
Management and storage of parameters / INI files.
Definition: Param.h:70
StreamType
Defines the type of the stream that should be handled.
Definition: StreamHandler.h:75
A more convenient string class.
Definition: String.h:60
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)