mCRL2
Loading...
Searching...
No Matches
mcrl2::log::logger Class Reference

Class for logging messages. More...

#include <logger.h>

Inheritance diagram for mcrl2::log::logger:
mcrl2::utilities::noncopyable

Public Member Functions

 logger (const log_level_t l)
 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.
 
std::ostringstream & get ()
 

Static Public Member Functions

static void register_output_policy (output_policy &policy)
 Register output policy.
 
static void unregister_output_policy (output_policy &policy)
 Unregister output policy.
 
static void clear_output_policies ()
 Clear all output policies.
 
static void set_reporting_level (const log_level_t level)
 Set reporting level.
 
static log_level_t get_reporting_level ()
 Get reporting level.
 
static void set_report_time_info ()
 Indicate that timing information should be printed.
 
static void clear_report_time_info ()
 Indicate that timing information should not be printed.
 
static bool get_report_time_info ()
 Get whether timing information is printed.
 

Static Protected Member Functions

static std::atomic< log_level_t > & log_level ()
 
static bool & m_print_time_information ()
 An indication whether time information should be printed.
 
static std::set< output_policy * > & output_policies ()
 Output policies.
 

Protected Attributes

std::ostringstream m_os
 Stream that is printed to internally Collects the full debug message that we are currently printing.
 
log_level_t m_level
 The loglevel of the current message.
 
time_t m_timestamp
 Timestamp of the current message.
 

Additional Inherited Members

- Private Member Functions inherited from mcrl2::utilities::noncopyable
 noncopyable ()=default
 
 noncopyable (const noncopyable &)=delete
 
noncopyableoperator= (const noncopyable &)=delete
 

Detailed Description

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&)

Definition at line 128 of file logger.h.

Constructor & Destructor Documentation

◆ logger()

mcrl2::log::logger::logger ( const log_level_t  l)
inline

Default constructor.

Definition at line 164 of file logger.h.

◆ ~logger()

mcrl2::log::logger::~logger ( )
inline

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.

Definition at line 174 of file logger.h.

Member Function Documentation

◆ clear_output_policies()

static void mcrl2::log::logger::clear_output_policies ( )
inlinestatic

Clear all output policies.

Definition at line 202 of file logger.h.

◆ clear_report_time_info()

static void mcrl2::log::logger::clear_report_time_info ( )
inlinestatic

Indicate that timing information should not be printed.

Definition at line 229 of file logger.h.

◆ get()

std::ostringstream & mcrl2::log::logger::get ( )
inline

Get access to the stream provided by the logger.

Parameters
[in]lLog level for the stream

Definition at line 243 of file logger.h.

◆ get_report_time_info()

static bool mcrl2::log::logger::get_report_time_info ( )
inlinestatic

Get whether timing information is printed.

Returns
True if time information is printed, otherwise false.

Definition at line 236 of file logger.h.

◆ get_reporting_level()

static log_level_t mcrl2::log::logger::get_reporting_level ( )
inlinestatic

Get reporting level.

Definition at line 217 of file logger.h.

◆ log_level()

static std::atomic< log_level_t > & mcrl2::log::logger::log_level ( )
inlinestaticprotected

Definition at line 141 of file logger.h.

◆ m_print_time_information()

static bool & mcrl2::log::logger::m_print_time_information ( )
inlinestaticprotected

An indication whether time information should be printed.

Definition at line 148 of file logger.h.

◆ output_policies()

static std::set< output_policy * > & mcrl2::log::logger::output_policies ( )
inlinestaticprotected

Output policies.

Definition at line 156 of file logger.h.

◆ register_output_policy()

static void mcrl2::log::logger::register_output_policy ( output_policy policy)
inlinestatic

Register output policy.

Definition at line 184 of file logger.h.

◆ set_report_time_info()

static void mcrl2::log::logger::set_report_time_info ( )
inlinestatic

Indicate that timing information should be printed.

Definition at line 223 of file logger.h.

◆ set_reporting_level()

static void mcrl2::log::logger::set_reporting_level ( const log_level_t  level)
inlinestatic

Set reporting level.

Parameters
[in]levelLog level

Definition at line 210 of file logger.h.

◆ unregister_output_policy()

static void mcrl2::log::logger::unregister_output_policy ( output_policy policy)
inlinestatic

Unregister output policy.

Definition at line 191 of file logger.h.

Member Data Documentation

◆ m_level

log_level_t mcrl2::log::logger::m_level
protected

The loglevel of the current message.

Definition at line 136 of file logger.h.

◆ m_os

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

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

Definition at line 133 of file logger.h.

◆ m_timestamp

time_t mcrl2::log::logger::m_timestamp
protected

Timestamp of the current message.

Definition at line 139 of file logger.h.


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