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 ()
 Get access to the stream provided by the logger.
 

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 std::optional< log_level_t > & thread_reporting_level ()
 The reporting level override of the current thread. When it has a value, it takes precedence over the global reporting level for mCRL2log statements on this thread; see scoped_reporting_level.
 
static log_level_t get_reporting_level ()
 Get reporting level, i.e. the level that is in effect on the current thread: the override of the current thread when one is active, and the global level otherwise.
 
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 std::atomic< 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 = 0L
 Timestamp of the current message.
 

Additional Inherited Members

- Private Member Functions inherited from mcrl2::utilities::noncopyable
 noncopyable ()=default
 
 ~noncopyable ()=default
 
 noncopyable (noncopyable &&)=default
 
noncopyable & operator= (noncopyable &&)=default
 
 noncopyable (const noncopyable &)=delete
 
noncopyable & operator= (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 241 of file logger.h.

◆ get()

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

Get access to the stream provided by the logger.

Definition at line 254 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 248 of file logger.h.

◆ get_reporting_level()

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

Get reporting level, i.e. the level that is in effect on the current thread: the override of the current thread when one is active, and the global level otherwise.

Definition at line 228 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 std::atomic< 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 235 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.

◆ thread_reporting_level()

static std::optional< log_level_t > & mcrl2::log::logger::thread_reporting_level ( )
inlinestatic

The reporting level override of the current thread. When it has a value, it takes precedence over the global reporting level for mCRL2log statements on this thread; see scoped_reporting_level.

Definition at line 218 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 = 0L
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: