RTI Connext Modern C++ API
Version 7.0.0
|
The singleton type used to configure RTI Connext logging. More...
#include <rti/config/Logger.hpp>
Public Member Functions | |
Verbosity | verbosity () |
Get the verbosity at which RTI Connext is currently logging diagnostic information. More... | |
Verbosity | verbosity_by_category (LogCategory category) |
Get the verbosity at which RTI Connext is currently logging diagnostic information in the given category. More... | |
void | verbosity (Verbosity verbosity) |
Set the verbosity at which RTI Connext will log diagnostic information. More... | |
void | verbosity_by_category (LogCategory category, Verbosity verbosity) |
Set the verbosity at which RTI Connext will log diagnostic information in the given category. More... | |
FILE * | output_file () |
Get the file to which the logged output is redirected. More... | |
void | output_file (FILE *out) |
Set the file to which the logged output is redirected. More... | |
void | output_file (const char *file_name) |
Set the name of the file to which the logged output is redirected. More... | |
void | output_file_set (const char *file_preffix, const char *file_suffix, int max_bytes, int max_files=dds::core::LENGTH_UNLIMITED) |
Set the name of the file to which the logged output is redirected. More... | |
void | output_handler (std::function< void(const LogMessage &)> handler) |
Redirects RTI Connext logging to a function. More... | |
void | reset_output_handler () |
Resets a previously set output handler. More... | |
PrintFormat | print_format () |
Get the current message format for the log level LogLevel::EXCEPTION. More... | |
void | print_format (PrintFormat print_format) |
Set the message format that RTI Connext will use to log diagnostic information for all the log levels, except for LogLevel::FATAL_ERROR. When the Activity Context is printed, the user can select the information that will be part of the Activity Context by using the API rti::config::activity_context::set_attribute_mask. More... | |
PrintFormat | print_format_by_log_level (LogLevel log_level) |
Get the current message format, by log level, that RTI Connext is using to log diagnostic information. More... | |
void | print_format_by_log_level (PrintFormat print_format, LogLevel log_level) |
Set the message format, by log level, that RTI Connext will use to log diagnostic information. When the Activity Context is printed, the user can select the information that will be part of the Activity Context by using the API rti::config::activity_context::set_attribute_mask. More... | |
Static Public Member Functions | |
static Logger & | instance () |
Get the singleton instance of this type. More... | |
The singleton type used to configure RTI Connext logging.
|
inlinestatic |
Get the singleton instance of this type.
References dds::core::LENGTH_UNLIMITED.
Referenced by rti::config::ScopedLoggerVerbosity::ScopedLoggerVerbosity(), and rti::config::ScopedLoggerVerbosity::~ScopedLoggerVerbosity().
Verbosity rti::config::Logger::verbosity | ( | ) |
Get the verbosity at which RTI Connext is currently logging diagnostic information.
The default verbosity if rti::config::Logger::verbosity is never called is rti::core::LogVerbosity::EXCEPTION.
If rti::config::Logger::verbosity_by_category has been used to set different verbosities for different categories of messages, this method will return the maximum verbosity of all categories.
Referenced by rti::config::ScopedLoggerVerbosity::ScopedLoggerVerbosity(), and rti::config::ScopedLoggerVerbosity::~ScopedLoggerVerbosity().
Verbosity rti::config::Logger::verbosity_by_category | ( | LogCategory | category | ) |
Get the verbosity at which RTI Connext is currently logging diagnostic information in the given category.
The default verbosity if rti::config::Logger::verbosity and rti::config::Logger::verbosity_by_category are never called is rti::core::LogVerbosity::EXCEPTION.
void rti::config::Logger::verbosity | ( | Verbosity | verbosity | ) |
Set the verbosity at which RTI Connext will log diagnostic information.
Note: Logging at high verbosities will be detrimental to your application's performance. Your default setting should typically remain at rti::core::LogVerbosity::WARNING or below. (The default verbosity if you never set it is rti::core::LogVerbosity::EXCEPTION.)
void rti::config::Logger::verbosity_by_category | ( | LogCategory | category, |
Verbosity | verbosity | ||
) |
Set the verbosity at which RTI Connext will log diagnostic information in the given category.
FILE* rti::config::Logger::output_file | ( | ) |
Get the file to which the logged output is redirected.
If no output file has been registered through rti::config::Logger::set_output_file, this method will return NULL. In this case, logged output will on most platforms go to standard out as if through printf.
void rti::config::Logger::output_file | ( | FILE * | out | ) |
Set the file to which the logged output is redirected.
The file passed may be NULL, in which case further logged output will be redirected to the platform-specific default output location (standard out on most platforms).
For better performance when log messages are generated frequently, the log messages are not flushed into a file immediately after they are generated. In other words, while writing a log message, RTI Connext only calls the function fwrite() (see https://pubs.opengroup.org/onlinepubs/009695399/functions/fwrite.html); it does not call the function fflush() (see https://pubs.opengroup.org/onlinepubs/009695399/functions/fflush.html). If your application requires a different flushing behavior, you may use rti::config::Logger::set_output_device to configure a custom logging device.
void rti::config::Logger::output_file | ( | const char * | file_name | ) |
Set the name of the file to which the logged output is redirected.
The name may be NULL, in which case further logged output will be redirected to the platform-specific default output location (standard out on most platforms).
See rti::config::Logger::set_output_file for the flushing behavior.
void rti::config::Logger::output_file_set | ( | const char * | file_preffix, |
const char * | file_suffix, | ||
int | max_bytes, | ||
int | max_files = dds::core::LENGTH_UNLIMITED |
||
) |
Set the name of the file to which the logged output is redirected.
The name may be NULL, in which case further logged output will be redirected to the platform-specific default output location (standard out on most platforms).
See rti::config::Logger::set_output_file for the flushing behavior.
|
inline |
Redirects RTI Connext logging to a function.
When a handler is set, log messages stop being directed to the standard output and are passed to the handler.
To direct logging back to the standard output, use reset_output_handler().
handler | A function or function object capable of receiving a const LogMessage& argument, the log message. |
The following example sets a handler that saves all log messages in a vector:
The char *
in the LogMessage
is only valid within the callback.
|
inline |
Resets a previously set output handler.
Directs RTI Connext logging back to the standard output.
References rti::config::LogMessage::is_security_message, rti::config::LogMessage::level, rti::config::LogMessage::message_id, and rti::config::LogMessage::text.
PrintFormat rti::config::Logger::print_format | ( | ) |
Get the current message format for the log level LogLevel::EXCEPTION.
Use rti::config::Logger::get_print_format_by_log_level to retrieve the format for other log levels.
If rti::config::Logger::set_print_format is never called, the default format is PrintFormat::DEFAULT.
void rti::config::Logger::print_format | ( | PrintFormat | print_format | ) |
Set the message format that RTI Connext will use to log diagnostic information for all the log levels, except for LogLevel::FATAL_ERROR. When the Activity Context is printed, the user can select the information that will be part of the Activity Context by using the API rti::config::activity_context::set_attribute_mask.
PrintFormat rti::config::Logger::print_format_by_log_level | ( | LogLevel | log_level | ) |
Get the current message format, by log level, that RTI Connext is using to log diagnostic information.
If rti::config::Logger::set_print_format is never called, the default format is PrintFormat::DEFAULT.
void rti::config::Logger::print_format_by_log_level | ( | PrintFormat | print_format, |
LogLevel | log_level | ||
) |
Set the message format, by log level, that RTI Connext will use to log diagnostic information. When the Activity Context is printed, the user can select the information that will be part of the Activity Context by using the API rti::config::activity_context::set_attribute_mask.