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 
97  void setLogLevel(const String & log_level);
98 
103 
105  virtual ~LogConfigHandler();
106 
107 protected:
108 
119 
127  std::set<String> & getConfigSetByName_(const String & stream_type);
128 
139 
140  std::set<String> debug_streams_;
141  std::set<String> info_streams_;
142  std::set<String> warn_streams_;
143  std::set<String> error_streams_;
144  std::set<String> fatal_streams_;
145 
146  std::map<String, StreamHandler::StreamType> stream_type_map_;
147 
148 private:
149  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, LogConfigHandler const & lch);
150 
151  // the pointer to the single instance
153 
154  // it is a singleton so we hide all c' and d'tors
155 
158 
161 
163  virtual LogConfigHandler & operator=(const LogConfigHandler & source);
164  };
165 
167  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, LogConfigHandler const & lch);
168 
169 } // end namespace OpenMS
170 
The LogConfigHandler provides the functionality to configure the internal logging of OpenMS algorithm...
Definition: LogConfigHandler.h:27
static LogConfigHandler * instance_
Definition: LogConfigHandler.h:152
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:143
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:141
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:144
std::map< String, StreamHandler::StreamType > stream_type_map_
Maps the registered streams to a StreamHandler::StreamType.
Definition: LogConfigHandler.h:146
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:140
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:142
Log Stream Class.
Definition: LogStream.h:292
Management and storage of parameters / INI files.
Definition: Param.h:44
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)