The LogConfigHandler provides the functionality to configure the internal logging of OpenMS algorithms that use the global instances of LogStream. More...
#include <OpenMS/CONCEPT/LogConfigHandler.h>
Public Member Functions | |
| Param | parse (const StringList &setting) |
| Translates the given list of parameter settings into a LogStream configuration. | |
| void | configure (const Param ¶m) |
Applies the given parameters (param) to the current configuration. | |
| ostream & | getStream (const String &stream_name) |
Returns a reference to the registered stream with the name stream_name. | |
| virtual | ~LogConfigHandler () |
| Destructor. | |
Static Public Member Functions | |
| static LogConfigHandler & | getInstance () |
| Returns the instance of LogConfigHandler. | |
Static Public Attributes | |
| static String | PARAM_NAME |
| Name of the parameter in which the configuration should be stored. | |
Protected Member Functions | |
| Logger::LogStream & | getLogStreamByName_ (const String &stream_name) |
| Returns the named global instance of the LogStream. (OpenMS::Log_debug, OpenMS::Log_info, OpenMS::Log_warn, OpenMS::Log_error, OpenMS::Log_fatal). | |
| std::set< String > & | getConfigSetByName_ (const String &stream_type) |
| Returns the correct set of registered streams for the given stream type (e.g. DEBUG, INFO, ..). | |
| StreamHandler::StreamType | getStreamTypeByName_ (const String &stream_type) |
Translates the given stream_type String into a valid StreamHandler::StreamType. | |
Protected Attributes | |
| std::set< String > | debug_streams_ |
| List of all streams that were appended to OpenMS::Log_debug. | |
| std::set< String > | info_streams_ |
| List of all streams that were appended to OpenMS::Log_info. | |
| std::set< String > | warn_streams_ |
| List of all streams that were appended to OpenMS::Log_warn. | |
| std::set< String > | error_streams_ |
| List of all streams that were appended to OpenMS::Log_error. | |
| std::set< String > | fatal_streams_ |
| List of all streams that were appended to OpenMS::Log_fatal. | |
| std::map< String, StreamHandler::StreamType > | stream_type_map_ |
| Maps the registered streams to a StreamHandler::StreamType. | |
Private Member Functions | |
| LogConfigHandler () | |
| Default constructor. | |
| LogConfigHandler (const LogConfigHandler &source) | |
| Copy constructor. | |
| virtual LogConfigHandler & | operator= (const LogConfigHandler &source) |
| Assignment operator. | |
Static Private Attributes | |
| static LogConfigHandler * | instance_ |
Friends | |
| std::ostream & | operator<< (std::ostream &os, LogConfigHandler const &lch) |
| Overload for the insertion operator (operator<<) to have a formated output of the LogConfigHandler. | |
The LogConfigHandler provides the functionality to configure the internal logging of OpenMS algorithms that use the global instances of LogStream.
| virtual ~LogConfigHandler | ( | ) | [virtual] |
Destructor.
| LogConfigHandler | ( | ) | [private] |
Default constructor.
| LogConfigHandler | ( | const LogConfigHandler & | source | ) | [private] |
Copy constructor.
| void configure | ( | const Param & | param | ) |
Applies the given parameters (param) to the current configuration.
<LOG_NAME> <ACTION> <PARAMETER> <STREAMTYPE>
LOG_NAME: DEBUG,INFO,WARNING,ERROR,FATAL_ERROR ACTION: add,remove,clear PARAMETER: for 'add'/'remove' it is the stream name (cout, cerr or a filename), 'clear' does not require any further parameter STREAMTYPE: FILE, STRING (for a StringStream, which you can grab by this name using getStream() )
You cannot specify a file named "cout" or "cerr" even if you specify streamtype 'FILE' - the handler will mistake this for the internal streams, but you can use "./cout" to print to a file named cout.
A classical configuration would contain a list of settings e.g.
DEBUG add debug.log FILE
INFO remove cout FILE (FILE will be ignored)
INFO add string_stream1 STRING
| Exception::ElementNotFound | If the LogStream (first argument) does not exist. | |
| Exception::FileNotWritable | If a file (or stream) should be opened as log file (or stream) that is not accesible. | |
| Exception::IllegalArgument | If a stream should be registered, that was already registered with a different type. |
Returns the correct set of registered streams for the given stream type (e.g. DEBUG, INFO, ..).
| stream_type | String representation of the stream type (DEBUG, INFO, ..) |
| ElementNotFoundException | if the given stream_type does not correspond to one of the known LogStreams |
| static LogConfigHandler& getInstance | ( | ) | [static] |
Returns the instance of LogConfigHandler.
| Logger::LogStream& getLogStreamByName_ | ( | const String & | stream_name | ) | [protected] |
Returns the named global instance of the LogStream. (OpenMS::Log_debug, OpenMS::Log_info, OpenMS::Log_warn, OpenMS::Log_error, OpenMS::Log_fatal).
| stream_name | Name of the stream. Should be DEBUG,INFO,WARNING,ERROR,FATAL_ERROR. |
| ElementNotFoundException | if the given stream_name does not correspond to one of the known LogStream instances |
| ostream& getStream | ( | const String & | stream_name | ) |
Returns a reference to the registered stream with the name stream_name.
| Exception::IllegalArgument | If no stream with the name stream_name was registered before. |
| StreamHandler::StreamType getStreamTypeByName_ | ( | const String & | stream_type | ) | [protected] |
Translates the given stream_type String into a valid StreamHandler::StreamType.
| stream_type | String representation of the StreamHandler::StreamType |
| Exception::IllegalArgument | is thrown when the passed stream_type does not correspond to an existing StreamHandler::StreamType |
| virtual LogConfigHandler& operator= | ( | const LogConfigHandler & | source | ) | [private, virtual] |
Assignment operator.
| Param parse | ( | const StringList & | setting | ) |
Translates the given list of parameter settings into a LogStream configuration.
Translates the given list of parameter settings into a LogStream configuration. Usually this list stems from a command line call.
Each element in the stringlist should follow this naming convention
<LOG_NAME> <ACTION> <PARAMETER>
with LOG_NAME: DEBUG,INFO,WARNING,ERROR,FATAL_ERROR ACTION: add,remove,clear PARAMETER: for 'add'/'remove' it is the stream name (cout, cerr or a filename), 'clear' does not require any further parameter
Example: DEBUG add debug.log
This function will not apply to settings to the log handlers. Use configure() for that.
| setting | StringList containing the configuration options |
| Exception::ParseError | In case of an invalid configuration. |
| std::ostream& operator<< | ( | std::ostream & | os, | |
| LogConfigHandler const & | lch | |||
| ) | [friend] |
Overload for the insertion operator (operator<<) to have a formated output of the LogConfigHandler.
std::set<String> debug_streams_ [protected] |
List of all streams that were appended to OpenMS::Log_debug.
std::set<String> error_streams_ [protected] |
List of all streams that were appended to OpenMS::Log_error.
std::set<String> fatal_streams_ [protected] |
List of all streams that were appended to OpenMS::Log_fatal.
std::set<String> info_streams_ [protected] |
List of all streams that were appended to OpenMS::Log_info.
LogConfigHandler* instance_ [static, private] |
String PARAM_NAME [static] |
Name of the parameter in which the configuration should be stored.
std::map<String, StreamHandler::StreamType> stream_type_map_ [protected] |
Maps the registered streams to a StreamHandler::StreamType.
std::set<String> warn_streams_ [protected] |
List of all streams that were appended to OpenMS::Log_warn.
| OpenMS / TOPP release 1.10.0 | Documentation generated on Thu Mar 7 2013 09:42:51 using doxygen 1.7.1 |