Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Attributes | Friends

LogConfigHandler Class Reference
[Concept]

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>

List of all members.

Public Member Functions

Param parse (const StringList &setting)
 Translates the given list of parameter settings into a LogStream configuration.
void configure (const Param &param)
 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 LogConfigHandlergetInstance ()
 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::LogStreamgetLogStreamByName_ (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< Stringdebug_streams_
 List of all streams that were appended to OpenMS::Log_debug.
std::set< Stringinfo_streams_
 List of all streams that were appended to OpenMS::Log_info.
std::set< Stringwarn_streams_
 List of all streams that were appended to OpenMS::Log_warn.
std::set< Stringerror_streams_
 List of all streams that were appended to OpenMS::Log_error.
std::set< Stringfatal_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 LogConfigHandleroperator= (const LogConfigHandler &source)
 Assignment operator.

Static Private Attributes

static LogConfigHandlerinstance_

Friends

std::ostream & operator<< (std::ostream &os, LogConfigHandler const &lch)
 Overload for the insertion operator (operator<<) to have a formated output of the LogConfigHandler.

Detailed Description

The LogConfigHandler provides the functionality to configure the internal logging of OpenMS algorithms that use the global instances of LogStream.


Constructor & Destructor Documentation

virtual ~LogConfigHandler (  )  [virtual]

Destructor.

LogConfigHandler (  )  [private]

Default constructor.

LogConfigHandler ( const LogConfigHandler source  )  [private]

Copy constructor.


Member Function Documentation

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

Exceptions:
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.
std::set<String>& getConfigSetByName_ ( const String stream_type  )  [protected]

Returns the correct set of registered streams for the given stream type (e.g. DEBUG, INFO, ..).

Parameters:
stream_type String representation of the stream type (DEBUG, INFO, ..)
Exceptions:
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).

Parameters:
stream_name Name of the stream. Should be DEBUG,INFO,WARNING,ERROR,FATAL_ERROR.
Exceptions:
ElementNotFoundException if the given stream_name does not correspond to one of the known LogStream instances
Returns:
A reference to the named LogStream
ostream& getStream ( const String stream_name  ) 

Returns a reference to the registered stream with the name stream_name.

Exceptions:
Exception::IllegalArgument If no stream with the name stream_name was registered before.
Returns:
Reference to the stream.
StreamHandler::StreamType getStreamTypeByName_ ( const String stream_type  )  [protected]

Translates the given stream_type String into a valid StreamHandler::StreamType.

Parameters:
stream_type String representation of the StreamHandler::StreamType
Exceptions:
Exception::IllegalArgument is thrown when the passed stream_type does not correspond to an existing StreamHandler::StreamType
Returns:
The requested 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.

Parameters:
setting StringList containing the configuration options
Exceptions:
Exception::ParseError In case of an invalid configuration.
Returns:
Param object containing all settings, that can be applied using the LogConfigHandler::configure() method

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
LogConfigHandler const &  lch 
) [friend]

Overload for the insertion operator (operator<<) to have a formated output of the LogConfigHandler.


Member Data Documentation

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.

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