RTI Distributed Logger Modern C++ API Version 7.2.0
rti::dist_logger::DistLogger Class Reference

This class contains RTI Distributed Logger singleton and the methods to configure and use it. More...

#include <DistLogger.hpp>

Inherits dds::core::Reference< DistLoggerImpl >.

Public Member Functions

void set_filter_level (int new_level)
 Sets the filter level for the singleton. More...
 
void set_print_format (const rti::config::PrintFormat &log_format)
 Sets PrintFormat of RTI Logger to the provided value. More...
 
void set_verbosity (const rti::config::LogCategory &category, const rti::config::Verbosity &verbosity)
 Updates the rti::config::LogCategory and the rti::config::Verbosity in RTI Logger to the provided value. More...
 
void log_message (int log_level, const char *message, const char *category)
 Logs a message at the specified level and with the specified category. More...
 
void log_message (int log_level, const std::string &message, const std::string &category)
 Logs a message at the specified level and with the specified category. More...
 
void log_message (int log_level, const char *message, const char *category, const dds::core::Time &timestamp)
 Performs the same function as log_message(int, const std::string&, const std::string&) except that it also allows specification of the message timestamp. More...
 
void log_message (int log_level, const std::string &message, const std::string &category, const dds::core::Time &timestamp)
 Performs the same function as log_message(int, const std::string&, const std::string&) except that it also allows specification of the message timestamp. More...
 
void fatal (const char *message)
 Logs a fatal message. More...
 
void fatal (const std::string &message)
 Logs a fatal message. More...
 
void severe (const char *message)
 Logs a severe message. More...
 
void severe (const std::string &message)
 Logs a severe message. More...
 
void error (const char *message)
 Logs a error message. More...
 
void error (const std::string &message)
 Logs a error message. More...
 
void warning (const char *message)
 Logs a warning message. More...
 
void warning (const std::string &message)
 Logs a warning message. More...
 
void notice (const char *message)
 Logs a notice message. More...
 
void notice (const std::string &message)
 Logs a notice message. More...
 
void info (const char *message)
 Logs a info message. More...
 
void info (const std::string &message)
 Logs a info message. More...
 
void debug (const char *message)
 Logs a debug message. More...
 
void debug (const std::string &message)
 Logs a debug message. More...
 
void trace (const char *message)
 Logs a trace message. More...
 
void trace (const std::string &message)
 Logs a trace message. More...
 
void log (int log_level, const char *message)
 Logs a message. More...
 
void log (int log_level, const std::string &message)
 Logs a message. More...
 
int get_fatal_log_level () const
 Gets Fatal log level. More...
 
int get_error_log_level () const
 Gets Error log level. More...
 
int get_warning_log_level () const
 Gets Warning log level. More...
 
int get_notice_log_level () const
 Gets Notice log level. More...
 
int get_info_log_level () const
 Gets Info log level. More...
 
int get_debug_log_level () const
 Gets Debug log level. More...
 

Static Public Member Functions

static DistLoggerget_instance ()
 Provides access to the DistLogger singleton. More...
 
static void finalize ()
 Finalizes the DistLogger singleton. More...
 
static void set_options (const rti::dist_logger::DistLoggerOptions &options)
 Assigns configurable options to RTI Distributed Logger before its creation. More...
 

Detailed Description

This class contains RTI Distributed Logger singleton and the methods to configure and use it.

This class is a singleton, so only one copy will be created. Use the DistLoggerOptions class to customize the singleton BEFORE creating it.

Member Function Documentation

◆ get_instance()

static DistLogger & rti::dist_logger::DistLogger::get_instance ( )
static

Provides access to the DistLogger singleton.

This method provides access to the singleton instance of the DistLogger. If the instance does not exist, it will be created. Note that no change in options is allowed after the singleton is created.

Returns
The singleton instance of the DistLogger.
Exceptions
dds::core::Erroron failure.

◆ finalize()

static void rti::dist_logger::DistLogger::finalize ( )
static

Finalizes the DistLogger singleton.

This method must be called before the application ends.

Exceptions
dds::core::Exceptionon failure.

◆ set_options()

static void rti::dist_logger::DistLogger::set_options ( const rti::dist_logger::DistLoggerOptions options)
static

Assigns configurable options to RTI Distributed Logger before its creation.

Assigns the values in the options to the DistLogger singleton before its creation. If the singleton was already created, this method has no effect. If a Domain Participant is provided ih the options, the Distributed Logger instance must be finalized before finalizing the Domain Participant Factory.

Parameters
optionsThe new options to be assigned to the DistLogger singleton.
Exceptions
dds::core::IllegalOperationErrorwhen the DistLogger singleton has already been created or dds::core::Exception on failure setting the options.

◆ set_filter_level()

void rti::dist_logger::DistLogger::set_filter_level ( int  new_level)

Sets the filter level for the singleton.

Filtering controls what type of log messages are sent. This enables filtering on the sending side (in the application using Distributed Logger). You can also enable filtering on the receiving side (such as in a tool that receives log messages, like RTI Admin Console or RTI Monitor).

Supported Filter Levels: See the table below. The default value is RTI_DL_INFO_LEVEL. The default value is RTI_DL_INFO_LEVEL.

Or see the IDL file provided with Distributed Logger (file: <RTI Connext Installation Folder>/resource/idl/distlog.idl).In the IDL file, there are language-specific bindings. Prepend the appropriate binding to the filter level shown in the IDL. For example, one of the filter levels in the IDL is INFO_LEVEL. To refer to this filter level in C++, use RTI_DL_INFO_LEVEL.

Log messages up to and including the specified filter level will pass through the filter and be sent on the network. For example, the WARNING level allows log messages up to and including the WARNING level (FATAL, SEVERE, ERROR, and WARNING) to be sent; any other log messages with numerically higher filter levels (INFO, DEBUG, and TRACE) will be filtered out and not sent.

Parameters
new_levelThe new filter level.
Exceptions
dds::core::Exceptionon failure.

The following table shows how RTI Connext DDS log levels map to RTI Distributed Logger log filter levels.

Not all RTI Distributed Logger levels appear in this table because there is not a one-to-one mapping between RTI Connext DDS and RTI Distributed Logger levels (there are more levels in RTI Distributed Logger). You can obtain the filter level using a constant defined in the Distributed Logger IDL file or a getter function in the Distributed Logger API.

Filter Levels
Connext DDS API constant Distributed Logger IDL constant Distributed Logger API getter
rti::config::LogLevel::FATAL_ERROR RTI_DL_FATAL_LEVEL get_fatal_log_level
rti::config::LogLevel::EXCEPTION RTI_DL_ERROR_LEVEL get_error_log_level
rti::config::LogLevel::WARNING RTI_DL_WARNING_LEVEL get_warning_log_level
rti::config::LogLevel::STATUS_LOCAL RTI_DL_NOTICE_LEVEL get_notice_log_level
rti::config::LogLevel::STATUS_REMOTE RTI_DL_INFO_LEVEL get_info_log_level
rti::config::LogLevel::STATUS_ALL RTI_DL_DEBUG_LEVEL get_debug_log_level

◆ set_print_format()

void rti::dist_logger::DistLogger::set_print_format ( const rti::config::PrintFormat &  log_format)

Sets PrintFormat of RTI Logger to the provided value.

This method is mostly a pass-through to the appropriate call in RTI DDS library, but it also has the benefit of keeping the state of RTI Logger and RTI Distributed Logger in sync.

Parameters
log_formatThe new PrintFormat.
Exceptions
dds::core::Erroron failure.

◆ set_verbosity()

void rti::dist_logger::DistLogger::set_verbosity ( const rti::config::LogCategory &  category,
const rti::config::Verbosity &  verbosity 
)

Updates the rti::config::LogCategory and the rti::config::Verbosity in RTI Logger to the provided value.

This method is mostly a pass-through to the appropriate call in RTI DDS library, but it also has the benefit of keeping the state of RTI Logger and RTI Distributed Logger in sync.

Parameters
categoryThe category for which to set the verbosity.
verbosityThe new verbosity level for the category.
Exceptions
dds::core::Erroron failure.

◆ log_message() [1/4]

void rti::dist_logger::DistLogger::log_message ( int  log_level,
const char *  message,
const char *  category 
)

Logs a message at the specified level and with the specified category.

Parameters
log_levelThe level of the log message.
messageThe message to log.
categoryThe category of the log message.

◆ log_message() [2/4]

void rti::dist_logger::DistLogger::log_message ( int  log_level,
const std::string &  message,
const std::string &  category 
)

Logs a message at the specified level and with the specified category.

Parameters
log_levelThe level of the log message.
messageThe message to log.
categoryThe category of the log message.

◆ log_message() [3/4]

void rti::dist_logger::DistLogger::log_message ( int  log_level,
const char *  message,
const char *  category,
const dds::core::Time &  timestamp 
)

Performs the same function as log_message(int, const std::string&, const std::string&) except that it also allows specification of the message timestamp.

Parameters
log_levelThe level of the log message.
messageThe message to log.
categoryThe category of the log message.
timestampThe timestamp of the log message.

◆ log_message() [4/4]

void rti::dist_logger::DistLogger::log_message ( int  log_level,
const std::string &  message,
const std::string &  category,
const dds::core::Time &  timestamp 
)

Performs the same function as log_message(int, const std::string&, const std::string&) except that it also allows specification of the message timestamp.

Parameters
log_levelThe level of the log message.
messageThe message to log.
categoryThe category of the log message.
timestampThe timestamp of the log message.

◆ fatal() [1/2]

void rti::dist_logger::DistLogger::fatal ( const char *  message)

Logs a fatal message.

The message received is logged using the default category and the RTI_DL_FATAL_LEVEL log level.

Parameters
messageThe message to log.

◆ fatal() [2/2]

void rti::dist_logger::DistLogger::fatal ( const std::string &  message)

Logs a fatal message.

The message received is logged using the default category and the RTI_DL_FATAL_LEVEL log level.

Parameters
messageThe message to log.

◆ severe() [1/2]

void rti::dist_logger::DistLogger::severe ( const char *  message)

Logs a severe message.

The message received is logged using the default category and the RTI_DL_SEVERE_LEVEL log level.

Parameters
messageThe message to log.

◆ severe() [2/2]

void rti::dist_logger::DistLogger::severe ( const std::string &  message)

Logs a severe message.

The message received is logged using the default category and the RTI_DL_SEVERE_LEVEL log level.

Parameters
messageThe message to log.

◆ error() [1/2]

void rti::dist_logger::DistLogger::error ( const char *  message)

Logs a error message.

The message received is logged using the default category and the RTI_DL_ERROR_LEVEL log level.

Parameters
messageThe message to log.

◆ error() [2/2]

void rti::dist_logger::DistLogger::error ( const std::string &  message)

Logs a error message.

The message received is logged using the default category and the RTI_DL_ERROR_LEVEL log level.

Parameters
messageThe message to log.

◆ warning() [1/2]

void rti::dist_logger::DistLogger::warning ( const char *  message)

Logs a warning message.

The message received is logged using the default category and the RTI_DL_WARNING_LEVEL log level.

Parameters
messageThe message to log.

◆ warning() [2/2]

void rti::dist_logger::DistLogger::warning ( const std::string &  message)

Logs a warning message.

The message received is logged using the default category and the RTI_DL_WARNING_LEVEL log level.

Parameters
messageThe message to log.

◆ notice() [1/2]

void rti::dist_logger::DistLogger::notice ( const char *  message)

Logs a notice message.

The message received is logged using the default category and the RTI_DL_NOTICE_LEVEL log level.

Parameters
messageThe message to log.

◆ notice() [2/2]

void rti::dist_logger::DistLogger::notice ( const std::string &  message)

Logs a notice message.

The message received is logged using the default category and the RTI_DL_NOTICE_LEVEL log level.

Parameters
messageThe message to log.

◆ info() [1/2]

void rti::dist_logger::DistLogger::info ( const char *  message)

Logs a info message.

The message received is logged using the default category and the RTI_DL_INFO_LEVEL log level.

Parameters
messageThe message to log.

◆ info() [2/2]

void rti::dist_logger::DistLogger::info ( const std::string &  message)

Logs a info message.

The message received is logged using the default category and the RTI_DL_INFO_LEVEL log level.

Parameters
messageThe message to log.

◆ debug() [1/2]

void rti::dist_logger::DistLogger::debug ( const char *  message)

Logs a debug message.

The message received is logged using the default category and the RTI_DL_DEBUG_LEVEL log level.

Parameters
messageThe message to log.

◆ debug() [2/2]

void rti::dist_logger::DistLogger::debug ( const std::string &  message)

Logs a debug message.

The message received is logged using the default category and the RTI_DL_DEBUG_LEVEL log level.

Parameters
messageThe message to log.

◆ trace() [1/2]

void rti::dist_logger::DistLogger::trace ( const char *  message)

Logs a trace message.

The message received is logged using the default category and the RTI_DL_TRACE_LEVEL log level.

Parameters
messageThe message to log.

◆ trace() [2/2]

void rti::dist_logger::DistLogger::trace ( const std::string &  message)

Logs a trace message.

The message received is logged using the default category and the RTI_DL_TRACE_LEVEL log level.

Parameters
messageThe message to log.

◆ log() [1/2]

void rti::dist_logger::DistLogger::log ( int  log_level,
const char *  message 
)

Logs a message.

The message received is logged using the default category and the given log level.

Parameters
log_levelThe level of the log message.
messageThe message to log.

◆ log() [2/2]

void rti::dist_logger::DistLogger::log ( int  log_level,
const std::string &  message 
)

Logs a message.

The message received is logged using the default category and the given log level.

Parameters
log_levelThe level of the log message.
messageThe message to log.

◆ get_fatal_log_level()

int rti::dist_logger::DistLogger::get_fatal_log_level ( ) const

Gets Fatal log level.

This method returns the currently defined value for RTI_DL_FATAL_LEVEL defined in <RTI Connext Installation Folder>/resource/idl/distlog.idl

See also
set_filter_level and log_message(int, const std::string&, const std::string&);
Returns
Fatal log level.

◆ get_error_log_level()

int rti::dist_logger::DistLogger::get_error_log_level ( ) const

Gets Error log level.

This method returns the currently defined value for RTI_DL_ERROR_LEVEL defined in <RTI Connext Installation Folder>/resource/idl/distlog.idl

See also
set_filter_level and log_message(int, const std::string&, const std::string&);
Returns
Error log level.

◆ get_warning_log_level()

int rti::dist_logger::DistLogger::get_warning_log_level ( ) const

Gets Warning log level.

This method returns the currently defined value for RTI_DL_WARNING_LEVEL defined in <RTI Connext Installation Folder>/resource/idl/distlog.idl

See also
set_filter_level and log_message(int, const std::string&, const std::string&);
Returns
Warning log level.

◆ get_notice_log_level()

int rti::dist_logger::DistLogger::get_notice_log_level ( ) const

Gets Notice log level.

This method returns the currently defined value for RTI_DL_NOTICE_LEVEL defined in <RTI Connext Installation Folder>/resource/idl/distlog.idl

See also
set_filter_level and log_message(int, const std::string&, const std::string&);
Returns
Notice log level.

◆ get_info_log_level()

int rti::dist_logger::DistLogger::get_info_log_level ( ) const

Gets Info log level.

This method returns the currently defined value for RTI_DL_INFO_LEVEL defined in <RTI Connext Installation Folder>/resource/idl/distlog.idl

See also
set_filter_level and log_message(int, const std::string&, const std::string&);
Returns
Info log level.

◆ get_debug_log_level()

int rti::dist_logger::DistLogger::get_debug_log_level ( ) const

Gets Debug log level.

This method returns the currently defined value for RTI_DL_DEBUG_LEVEL defined in <RTI Connext Installation Folder>/resource/idl/distlog.idl

See also
set_filter_level and log_message(int, const std::string&, const std::string&);
Returns
Debug log level.