RTI Connext Modern C++ API Version 7.3.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) |
Configure a set of files to redirect the logged output. 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 rti::config::LogLevel_def::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 rti::config::LogLevel_def::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... | |
void | emergency (const char *msg) |
Logs message with rti::config::SyslogLevel::emergency and rti::config::LogCategory_def::user. More... | |
void | alert (const char *msg) |
Logs message with rti::config::SyslogLevel::alert and rti::config::LogCategory_def::user. More... | |
void | critical (const char *msg) |
Logs message with rti::config::SyslogLevel::critical and rti::config::LogCategory_def::user. More... | |
void | error (const char *msg) |
Logs message with rti::config::SyslogLevel::error and rti::config::LogCategory_def::user. More... | |
void | warning (const char *msg) |
Logs message with rti::config::SyslogLevel::warning and rti::config::LogCategory_def::user. More... | |
void | notice (const char *msg) |
Logs message with rti::config::SyslogLevel::notice and rti::config::LogCategory_def::user. More... | |
void | informational (const char *msg) |
Logs message with rti::config::SyslogLevel::informational and rti::config::LogCategory_def::user. More... | |
void | debug (const char *msg) |
Logs message with rti::config::SyslogLevel::debug and rti::config::LogCategory_def::user. More... | |
void | emergency (std::string_view msg) |
Logs message with rti::config::SyslogLevel::emergency and rti::config::LogCategory_def::user. More... | |
void | alert (std::string_view msg) |
Logs message with rti::config::SyslogLevel::alert and rti::config::LogCategory_def::user. More... | |
void | critical (std::string_view msg) |
Logs message with rti::config::SyslogLevel::critical and rti::config::LogCategory_def::user. More... | |
void | error (std::string_view msg) |
Logs message with rti::config::SyslogLevel::error and rti::config::LogCategory_def::user. More... | |
void | warning (std::string_view msg) |
Logs message with rti::config::SyslogLevel::warning and rti::config::LogCategory_def::user. More... | |
void | notice (std::string_view msg) |
Logs message with rti::config::SyslogLevel::notice and rti::config::LogCategory_def::user. More... | |
void | informational (std::string_view msg) |
Logs message with rti::config::SyslogLevel::informational and rti::config::LogCategory_def::user. More... | |
void | debug (std::string_view msg) |
Logs message with rti::config::SyslogLevel::debug and rti::config::LogCategory_def::user. 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.
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::config::Verbosity_def::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::config::Verbosity_def::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::config::Verbosity_def::warning or below. (The default verbosity if you never set it is rti::config::Verbosity_def::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::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::output_handler 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::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 |
||
) |
Configure a set of files to redirect the logged output.
The logged output will be redirected to a set of files whose names are configured with a prefix and a suffix. The maximum number of bytes configures how many bytes to write into a file before opening the next file. After reaching the maximum number of files, the first one is overwritten.
For example, if the prefix is 'Foo', the suffix is '.txt', the max number of bytes is 1GB, and the max number of files is 3, the logger will create (at most) these files: Foo1.txt, Foo2.txt, and Foo3.txt. It will write to Foo1.txt, and after writing 1GB, it will move on to Foo2.txt, then to Foo3.txt, then to Foo1.txt again, and so on.
To stop logging to these files and redirect the output to the platform-specific location, pass NULL, NULL, 0, 0.
See rti::config::Logger::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.
PrintFormat rti::config::Logger::print_format | ( | ) |
Get the current message format for the log level rti::config::LogLevel_def::EXCEPTION.
Use rti::config::Logger::get_print_format_by_log_level to retrieve the format for other log levels.
If rti::config::Logger::print_format is never called, the default format is PrintFormat_def::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 rti::config::LogLevel_def::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::print_format is never called, the default format is PrintFormat_def::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().
void rti::config::Logger::emergency | ( | const char * | msg | ) |
Logs message with rti::config::SyslogLevel::emergency and rti::config::LogCategory_def::user.
void rti::config::Logger::alert | ( | const char * | msg | ) |
Logs message with rti::config::SyslogLevel::alert and rti::config::LogCategory_def::user.
void rti::config::Logger::critical | ( | const char * | msg | ) |
Logs message with rti::config::SyslogLevel::critical and rti::config::LogCategory_def::user.
void rti::config::Logger::error | ( | const char * | msg | ) |
Logs message with rti::config::SyslogLevel::error and rti::config::LogCategory_def::user.
void rti::config::Logger::warning | ( | const char * | msg | ) |
Logs message with rti::config::SyslogLevel::warning and rti::config::LogCategory_def::user.
void rti::config::Logger::notice | ( | const char * | msg | ) |
Logs message with rti::config::SyslogLevel::notice and rti::config::LogCategory_def::user.
void rti::config::Logger::informational | ( | const char * | msg | ) |
Logs message with rti::config::SyslogLevel::informational and rti::config::LogCategory_def::user.
void rti::config::Logger::debug | ( | const char * | msg | ) |
Logs message with rti::config::SyslogLevel::debug and rti::config::LogCategory_def::user.
void rti::config::Logger::emergency | ( | std::string_view | msg | ) |
Logs message with rti::config::SyslogLevel::emergency and rti::config::LogCategory_def::user.
void rti::config::Logger::alert | ( | std::string_view | msg | ) |
Logs message with rti::config::SyslogLevel::alert and rti::config::LogCategory_def::user.
void rti::config::Logger::critical | ( | std::string_view | msg | ) |
Logs message with rti::config::SyslogLevel::critical and rti::config::LogCategory_def::user.
void rti::config::Logger::error | ( | std::string_view | msg | ) |
Logs message with rti::config::SyslogLevel::error and rti::config::LogCategory_def::user.
void rti::config::Logger::warning | ( | std::string_view | msg | ) |
Logs message with rti::config::SyslogLevel::warning and rti::config::LogCategory_def::user.
void rti::config::Logger::notice | ( | std::string_view | msg | ) |
Logs message with rti::config::SyslogLevel::notice and rti::config::LogCategory_def::user.
void rti::config::Logger::informational | ( | std::string_view | msg | ) |
Logs message with rti::config::SyslogLevel::informational and rti::config::LogCategory_def::user.
void rti::config::Logger::debug | ( | std::string_view | msg | ) |
Logs message with rti::config::SyslogLevel::debug and rti::config::LogCategory_def::user.