mcrl2::log::logger

Include file:

#include "mcrl2/utilities/logger.h
class mcrl2::log::logger

Class for logging messages.

Based on a description in the article “Logging In C++”, Petru Marginean Dr. Dobb’s Journal, September 5, 2007 (url: http://drdobbs.com/cpp/201804215) Requires that OutputPolicy is a class which as a static member output(const std::string&)

Protected attributes

std::string mcrl2::log::logger::m_hint

The message hint of the current message.

log_level_t mcrl2::log::logger::m_level

The loglevel of the current message.

std::ostringstream mcrl2::log::logger::m_os

Stream that is printed to internally Collects the full debug message that we are currently printing.

time_t mcrl2::log::logger::m_timestamp

Timestamp of the current message.

Private member functions

logger(const logger&)
logger &operator=(const logger&)

Protected static member functions

static std::map<std::string, log_level_t> &hint_to_level()

Mapping of message hint to loglevel. This allows a finegrained control of log messages to log levels. It can e.g. be set that for some message hint all messages up to debug level are printed, whereas for other message hints no messages are printed at all.

static bool &m_print_time_information()

An indication whether time information should be printed.

static std::set<output_policy *> &output_policies()

Output policies.

Public static member functions

static void clear_output_policies()

Clear all output policies.

static void clear_report_time_info()

Indicate that timing information should not be printed.

static void clear_reporting_level(const std::string &hint)

Clear reporting level.

Parameters:

  • hint Reset the log level for hint
static std::string default_hint()

Default hint (empty)

static log_level_t default_reporting_level()

The default log level that is used if no specific log level has been set.

static bool get_report_time_info()

Get whether timing information is printed.

Returns: True if time information is printed, otherwise false.

static log_level_t get_reporting_level(const std::string &hint = default_hint())

Get reporting level.

Parameters:

  • hint The hint for which to get log level
static void register_output_policy(output_policy &policy)

Register output policy.

static void set_report_time_info()

Indicate that timing information should be printed.

static void set_reporting_level(const log_level_t level, const std::string &hint = default_hint())

Set reporting level.

Parameters:

  • level Log level
  • hint The hint for which to set log level
static void unregister_output_policy(output_policy &policy)

Unregister output policy.

Public member functions

std::ostringstream &get(const log_level_t l, const std::string &hint = default_hint())

Get access to the stream provided by the logger.

Parameters:

  • l Log level for the stream
  • hint The hint for which the stream has to be provided.
logger()

Default constructor.

~logger()

Destructor; flushes output. Flushing during destruction is important to confer thread safety to the logging mechanism. Requires that output performs output in an atomic way.