ContRap-Core
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes

crp::Logger Class Reference

Logger collects logging messages and returns them to a desired target on demand. More...

#include <logger.h>

Public Member Functions

 ~Logger ()
 Releases the memory.
void set_message_level (MessageLevel message_level)
 Sets the debug level.
MessageLevel get_message_level ()
 Returns the current debug level.
void clear_filters ()
 Clears the filters.
void set_filter (const std::string &sender, bool status)
 Adds a sender filter status.
void log_to_stream (std::ostream *stream)
 Configures the logger to log to a stream.
void log (const std::string &message, MessageType type=COMMENT_MESSAGE, const std::string &sender="")
 Adds a message to log.
LoggerMessage get_next_message ()
 Returns the next message to process.
bool has_messages ()
 Returns true if the logger has pending messages.
void set_stdout_echo (bool status)
 Sets if the logger should echo the logged messages to the standard output.
void dump_to_stdout ()
 Dumps the logger content to standard output.

Static Public Member Functions

static Logger * get_instance ()
 Returns the instance of the logger.
static bool is_finalized ()
 Returns true if the logger is finalized.

Protected Attributes

Dispatcher * dispatcher
 Dispatcher.
std::queue< LoggerMessage > messages
 Container for the messages.
std::ostream * stream
 Logging stream.
MessageLevel message_level
 Debug message level.
bool stdout_echo
 If this flag is set to true the logger echoes to the standard output.
std::map< std::string, bool > filters
 Sender filters.

Static Protected Attributes

static Logger * logger
 Instance of the logger.
static bool finalized
 Set to true if the logger is initialized.

Detailed Description

Logger collects logging messages and returns them to a desired target on demand.


Constructor & Destructor Documentation

crp::Logger::~Logger ( )

Releases the memory.


Member Function Documentation

void crp::Logger::clear_filters ( )

Clears the filters.

void crp::Logger::dump_to_stdout ( )

Dumps the logger content to standard output.

static Logger* crp::Logger::get_instance ( ) [static]

Returns the instance of the logger.

MessageLevel crp::Logger::get_message_level ( ) [inline]

Returns the current debug level.

Returns:
Debug level
LoggerMessage crp::Logger::get_next_message ( )

Returns the next message to process.

Returns:
Next message to process
bool crp::Logger::has_messages ( ) [inline]

Returns true if the logger has pending messages.

Returns:
Boolean value
static bool crp::Logger::is_finalized ( ) [inline, static]

Returns true if the logger is finalized.

Returns:
True if the logger is finalized.
void crp::Logger::log ( const std::string &  message,
MessageType  type = COMMENT_MESSAGE,
const std::string &  sender = "" 
)

Adds a message to log.

Parameters:
messageString of the message
typeType of the message
senderA string identifying the caller
void crp::Logger::log_to_stream ( std::ostream *  stream)

Configures the logger to log to a stream.

Parameters:
streamOutput stream, e.g. file
void crp::Logger::set_filter ( const std::string &  sender,
bool  status 
)

Adds a sender filter status.

Parameters:
senderName of the sender allowed to log.
statusIf set to false the sender is not allowed to log.
void crp::Logger::set_message_level ( MessageLevel  message_level)

Sets the debug level.

Parameters:
debug_levelNew debug level
void crp::Logger::set_stdout_echo ( bool  status) [inline]

Sets if the logger should echo the logged messages to the standard output.

Parameters:
statusIf set to true echo is enabled.

Field Documentation

Dispatcher* crp::Logger::dispatcher [protected]

Dispatcher.

std::map<std::string, bool> crp::Logger::filters [protected]

Sender filters.

bool crp::Logger::finalized [static, protected]

Set to true if the logger is initialized.

Logger* crp::Logger::logger [static, protected]

Instance of the logger.

Debug message level.

std::queue<LoggerMessage> crp::Logger::messages [protected]

Container for the messages.

bool crp::Logger::stdout_echo [protected]

If this flag is set to true the logger echoes to the standard output.

std::ostream* crp::Logger::stream [protected]

Logging stream.


The documentation for this class was generated from the following file: