OpenMS
2.5.0
|
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. More... | |
void | configure (const Param ¶m) |
Applies the given parameters (param ) to the current configuration. More... | |
std::ostream & | getStream (const String &stream_name) |
Returns a reference to the registered stream with the name stream_name . More... | |
virtual | ~LogConfigHandler () |
Destructor. More... | |
Static Public Member Functions | |
static LogConfigHandler & | getInstance () |
Returns the instance of LogConfigHandler. More... | |
Static Public Attributes | |
static String | PARAM_NAME |
Name of the parameter in which the configuration should be stored. More... | |
Protected Member Functions | |
Logger::LogStream & | getLogStreamByName_ (const String &stream_name) |
Returns the named global instance of the LogStream. (OpenMS::OpenMS_Log_debug, OpenMS::OpenMS_Log_info, OpenMS::OpenMS_Log_warn, OpenMS::OpenMS_Log_error, OpenMS::OpenMS_Log_fatal) More... | |
std::set< String > & | getConfigSetByName_ (const String &stream_type) |
Returns the correct set of registered streams for the given stream type (e.g. DEBUG, INFO, ..) More... | |
StreamHandler::StreamType | getStreamTypeByName_ (const String &stream_type) |
Translates the given stream_type String into a valid StreamHandler::StreamType. More... | |
Protected Attributes | |
std::set< String > | debug_streams_ |
List of all streams that were appended to OpenMS::OpenMS_Log_debug. More... | |
std::set< String > | info_streams_ |
List of all streams that were appended to OpenMS::OpenMS_Log_info. More... | |
std::set< String > | warn_streams_ |
List of all streams that were appended to OpenMS::OpenMS_Log_warn. More... | |
std::set< String > | error_streams_ |
List of all streams that were appended to OpenMS::OpenMS_Log_error. More... | |
std::set< String > | fatal_streams_ |
List of all streams that were appended to OpenMS::OpenMS_Log_fatal. More... | |
std::map< String, StreamHandler::StreamType > | stream_type_map_ |
Maps the registered streams to a StreamHandler::StreamType. More... | |
Private Member Functions | |
LogConfigHandler () | |
Default constructor. More... | |
LogConfigHandler (const LogConfigHandler &source) | |
Copy constructor. More... | |
virtual LogConfigHandler & | operator= (const LogConfigHandler &source) |
Assignment operator. More... | |
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 formatted output of the LogConfigHandler. More... | |
The LogConfigHandler provides the functionality to configure the internal logging of OpenMS algorithms that use the global instances of LogStream.
|
virtual |
Destructor.
|
private |
Default constructor.
|
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 accessible. |
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 |
Returns the instance of LogConfigHandler.
|
protected |
Returns the named global instance of the LogStream. (OpenMS::OpenMS_Log_debug, OpenMS::OpenMS_Log_info, OpenMS::OpenMS_Log_warn, OpenMS::OpenMS_Log_error, OpenMS::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 |
std::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. |
|
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 |
|
privatevirtual |
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. |
|
friend |
Overload for the insertion operator (operator<<) to have a formatted output of the LogConfigHandler.
|
protected |
List of all streams that were appended to OpenMS::OpenMS_Log_debug.
|
protected |
List of all streams that were appended to OpenMS::OpenMS_Log_error.
|
protected |
List of all streams that were appended to OpenMS::OpenMS_Log_fatal.
|
protected |
List of all streams that were appended to OpenMS::OpenMS_Log_info.
|
staticprivate |
|
static |
Name of the parameter in which the configuration should be stored.
|
protected |
Maps the registered streams to a StreamHandler::StreamType.
|
protected |
List of all streams that were appended to OpenMS::OpenMS_Log_warn.