OpenMS
LogConfigHandler.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg$
6 // $Authors: Stephan Aiche$
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
13 
16 
17 namespace OpenMS
18 {
19 
26  class OPENMS_DLLAPI LogConfigHandler
27  {
28 public:
29 
30  static String PARAM_NAME;
31 
56  Param parse(const StringList & setting);
57 
82  void configure(const Param & param);
83 
91  std::ostream & getStream(const String & stream_name);
92 
107  void setLogLevel(const String & log_level);
108 
113 
115  virtual ~LogConfigHandler();
116 
117 protected:
118 
129 
137  std::set<String> & getConfigSetByName_(const String & stream_type);
138 
149 
150  std::set<String> debug_streams_;
151  std::set<String> info_streams_;
152  std::set<String> warn_streams_;
153  std::set<String> error_streams_;
154  std::set<String> fatal_streams_;
155 
156  std::map<String, StreamHandler::StreamType> stream_type_map_;
157 
158 private:
159  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, LogConfigHandler const & lch);
160 
161  // the pointer to the single instance
163 
164  // it is a singleton so we hide all c' and d'tors
165 
168 
171 
173  virtual LogConfigHandler & operator=(const LogConfigHandler & source);
174  };
175 
177  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, LogConfigHandler const & lch);
178 
179 } // end namespace OpenMS
180 
The LogConfigHandler provides the functionality to configure the internal logging of OpenMS algorithm...
Definition: LogConfigHandler.h:27
static LogConfigHandler * instance_
Definition: LogConfigHandler.h:162
std::ostream & getStream(const String &stream_name)
Returns a reference to the registered stream with the name stream_name.
LogConfigHandler()
Default constructor.
void setLogLevel(const String &log_level)
Sets a minimum log_level by removing all streams from loggers lower than that level,...
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:153
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:151
static String PARAM_NAME
Name of the parameter in which the configuration should be stored.
Definition: LogConfigHandler.h:30
std::set< String > fatal_streams_
List of all streams that were appended to OpenMS::OpenMS_Log_fatal.
Definition: LogConfigHandler.h:154
std::map< String, StreamHandler::StreamType > stream_type_map_
Maps the registered streams to a StreamHandler::StreamType.
Definition: LogConfigHandler.h:156
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:150
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:152
Log Stream Class.
Definition: LogStream.h:292
Management and storage of parameters / INI files.
Definition: Param.h:46
StreamType
Defines the type of the stream that should be handled.
Definition: StreamHandler.h:49
A more convenient string class.
Definition: String.h:34
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)