|
iceoryx2
C++ Bindings
|
This logger is used for tests. It caches all the log messages and prints them to the console when a test fails. For debug purposes this behaviour can be overwritten with the 'IOX2_TESTING_ALLOW_LOG' environment variable, e.g. 'IOX2_TESTING_ALLOW_LOG=ON ./hoofs_moduletests –gtest_filter=SharedMemoryObject_Test*'. Furthermore, it can also be used to check for the occurrence on specific log messages, e.g. when a function is expected to log an error. More...
#include <testing_logger.hpp>
Public Member Functions | |
| ~TestingLogger () override=default | |
| TestingLogger (const TestingLogger &)=delete | |
| TestingLogger (TestingLogger &&)=delete | |
| auto | operator= (const TestingLogger &) -> TestingLogger &=delete |
| auto | operator= (TestingLogger &&) -> TestingLogger &=delete |
| auto | clear_log_buffer () noexcept -> void |
| Removes all log messages from the internal cache. This is automatically done at the start of each test. | |
| auto | print_log_buffer () noexcept -> void |
| Prints all log messages from the internal cache. This is automatically done at the end of a failed test. | |
| Public Member Functions inherited from iox2::legacy::log::internal::Logger< ConsoleLogger > | |
| Logger ()=default | |
| Logger (const Logger &)=delete | |
| Logger (Logger &&)=delete | |
| Logger & | operator= (const Logger &)=delete |
| Logger & | operator= (Logger &&)=delete |
| ~Logger ()=default | |
| Public Member Functions inherited from iox2::legacy::log::ConsoleLogger | |
| virtual | ~ConsoleLogger ()=default |
| ConsoleLogger (const ConsoleLogger &)=delete | |
| ConsoleLogger (ConsoleLogger &&)=delete | |
| ConsoleLogger & | operator= (const ConsoleLogger &)=delete |
| ConsoleLogger & | operator= (ConsoleLogger &&)=delete |
Static Public Member Functions | |
| static auto | init () noexcept -> void |
| Initialized the logger. This should be called in the main function of the test binary. | |
| static auto | get_number_of_log_messages () noexcept -> uint64_t |
| Number of caches log messages. | |
| static auto | check_log_message_if_log_level_is_supported (legacy::log::LogLevel log_level, const std::function< void(const std::vector< std::string > &)> &check) -> void |
| Runs the provided checker function for the collected log messages. | |
| static constexpr auto | does_logger_support_log_level (const legacy::log::LogLevel log_level) noexcept -> bool |
| Checks if the the LogLevel is above the minimal supported LogLevel compiled into the binary. | |
| Static Public Member Functions inherited from iox2::legacy::log::internal::Logger< ConsoleLogger > | |
| static Logger & | get () noexcept |
| Access to the logger singleton instance. | |
| static void | init (const LogLevel logLevel=logLevelFromEnvOr(LogLevel::Info)) noexcept |
| Initializes the logger. | |
| static void | setActiveLogger (Logger &newLogger) noexcept |
| Replaces the default logger with the specified one. | |
| Static Public Member Functions inherited from iox2::legacy::log::ConsoleLogger | |
| static LogLevel | getLogLevel () noexcept |
| Obtain the current log level. | |
| static void | setLogLevel (const LogLevel logLevel) noexcept |
| Sets a new log level. | |
Protected Member Functions | |
| void | flush () noexcept override |
| Protected Member Functions inherited from iox2::legacy::log::ConsoleLogger | |
| ConsoleLogger () noexcept=default | |
| virtual void | initLogger (const LogLevel) noexcept |
| virtual void | createLogMessageHeader (const bb::detail::SourceLocation location, const LogLevel logLevel) noexcept |
| LogBuffer | getLogBuffer () const noexcept |
| void | assumeFlushed () noexcept |
| void | logString (const char *message) noexcept |
| void | logChar (const char value) noexcept |
| void | logBool (const bool value) noexcept |
| template<typename T, typename std::enable_if_t< std::is_arithmetic< T >::value, bool > = 0> | |
| void | logDec (const T value) noexcept |
| template<typename T, typename std::enable_if_t<(std::is_integral< T >::value &&std::is_unsigned< T >::value)||std::is_floating_point< T >::value||std::is_pointer< T >::value, bool > = 0> | |
| void | logHex (const T value) noexcept |
| template<typename T, typename std::enable_if_t< std::is_integral< T >::value &&std::is_unsigned< T >::value, bool > = 0> | |
| void | logOct (const T value) noexcept |
| template<typename T, typename std::enable_if_t< std::is_integral< T >::value &&std::is_unsigned< T >::value, bool > = 0> | |
| void | logBin (const T value) noexcept |
| void | logRaw (const void *const data, const uint64_t size) noexcept |
This logger is used for tests. It caches all the log messages and prints them to the console when a test fails. For debug purposes this behaviour can be overwritten with the 'IOX2_TESTING_ALLOW_LOG' environment variable, e.g. 'IOX2_TESTING_ALLOW_LOG=ON ./hoofs_moduletests –gtest_filter=SharedMemoryObject_Test*'. Furthermore, it can also be used to check for the occurrence on specific log messages, e.g. when a function is expected to log an error.
Definition at line 65 of file testing_logger.hpp.
|
overridedefault |
|
delete |
References TestingLogger().
Referenced by get_number_of_log_messages(), init(), operator=(), operator=(), TestingLogger(), and TestingLogger().
|
delete |
References TestingLogger().
|
inlinestatic |
Runs the provided checker function for the collected log messages.
Definition at line 153 of file testing_logger.hpp.
References does_logger_support_log_level().
|
inlinenoexcept |
Removes all log messages from the internal cache. This is automatically done at the start of each test.
Definition at line 123 of file testing_logger.hpp.
|
inlinestaticconstexprnoexcept |
Checks if the the LogLevel is above the minimal supported LogLevel compiled into the binary.
| [in] | log_level | is the log level to check if it is supported |
Definition at line 164 of file testing_logger.hpp.
References iox2::legacy::log::MINIMAL_LOG_LEVEL.
Referenced by check_log_message_if_log_level_is_supported().
|
inlineoverrideprotectedvirtualnoexcept |
Reimplemented from iox2::legacy::log::ConsoleLogger.
Definition at line 169 of file testing_logger.hpp.
References iox2::legacy::log::ConsoleLogger::assumeFlushed(), iox2::legacy::log::ConsoleLogger::flush(), and iox2::legacy::log::ConsoleLogger::getLogBuffer().
|
inlinestaticnoexcept |
Number of caches log messages.
Definition at line 145 of file testing_logger.hpp.
References iox2::legacy::log::internal::Logger< ConsoleLogger >::get(), and TestingLogger().
|
inlinestaticnoexcept |
Initialized the logger. This should be called in the main function of the test binary.
Definition at line 91 of file testing_logger.hpp.
References iox2::legacy::log::equalStrings(), iox2::legacy::log::internal::Logger< ConsoleLogger >::init(), iox2::legacy::log::logLevelFromEnvOr(), iox2::legacy::log::internal::Logger< ConsoleLogger >::setActiveLogger(), TestingLogger(), and iox2::legacy::log::Trace.
|
delete |
References TestingLogger().
|
delete |
References TestingLogger().
|
inlinenoexcept |
Prints all log messages from the internal cache. This is automatically done at the end of a failed test.
Definition at line 129 of file testing_logger.hpp.
References iox2::log().