iceoryx2
C++ Bindings
Loading...
Searching...
No Matches
iox2::legacy::log::LogStream Class Reference

This class provides the public interface to the logger and is used with the 'IOX2_LOG' macro. In order to add support for custom data types 'operator<<' needs to be implement for the custom type. More...

#include <logstream.hpp>

Public Member Functions

 LogStream (Logger &logger, const bb::detail::SourceLocation location, const LogLevel logLevel) noexcept
 Constructor for a LogStream object with an externally provided logger.
 LogStream (const bb::detail::SourceLocation location, const LogLevel logLevel) noexcept
 Constructor for a LogStream object with the logger from iox2::legacy::log::Logger::get.
virtual ~LogStream () noexcept
 LogStream (const LogStream &)=delete
 LogStream (LogStream &&)=delete
LogStream & operator= (const LogStream &)=delete
LogStream & operator= (LogStream &&)=delete
LogStream & self () noexcept
 Helper function to convert a r-value reference into a l-value reference in order to be able to extend the data types which can be logged with LogStream object. Without this, one would need to always log a builtin type before a custom type could be logged.
LogStream & operator<< (const char *cstr) noexcept
 Logging support for C-style strings.
LogStream & operator<< (const std::string &str) noexcept
 Logging support for std::string.
LogStream & operator<< (const bool val) noexcept
 Logging support for 'boolean'.
LogStream & operator<< (const char val) noexcept
 Logging support for 'char'.
LogStream & operator<< (const signed char val) noexcept
 Logging support for 'signed char'.
LogStream & operator<< (const unsigned char val) noexcept
 Logging support for 'unsigned char'.
LogStream & operator<< (const short val) noexcept
 Logging support for 'short'.
LogStream & operator<< (const unsigned short val) noexcept
 Logging support for 'unsigned short'.
LogStream & operator<< (const int val) noexcept
 Logging support for 'int'.
LogStream & operator<< (const unsigned int val) noexcept
 Logging support for 'unsigned int'.
LogStream & operator<< (const long val) noexcept
 Logging support for 'long'.
LogStream & operator<< (const unsigned long val) noexcept
 Logging support for 'unsigned long'.
LogStream & operator<< (const long long val) noexcept
 Logging support for 'long long'.
LogStream & operator<< (const unsigned long long val) noexcept
 Logging support for 'unsigned long long'.
LogStream & operator<< (const float val) noexcept
 Logging support for 'float'.
LogStream & operator<< (const double val) noexcept
 Logging support for 'double'.
LogStream & operator<< (const long double val) noexcept
 Logging support for 'long double'.
template<typename T, typename std::enable_if_t< std::is_integral< T >::value, bool > = 0>
LogStream & operator<< (const LogHex< T > &&val) noexcept
 Logging support for integral numbers in hexadecimal format.
template<typename T, typename std::enable_if_t< std::is_floating_point< T >::value, bool > = 0>
LogStream & operator<< (const LogHex< T > &&val) noexcept
 Logging support for floating point numbers in hexadecimal format.
LogStream & operator<< (const LogHex< const void *const > &&val) noexcept
 Logging support for pointer in hexadecimal format.
template<typename T, typename std::enable_if_t< std::is_integral< T >::value, bool > = 0>
LogStream & operator<< (const LogOct< T > &&val) noexcept
 Logging support for integral numbers in octal format.
template<typename T, typename std::enable_if_t< std::is_integral< T >::value, bool > = 0>
LogStream & operator<< (const LogBin< T > &&val) noexcept
 Logging support for integral numbers in binary format.
LogStream & operator<< (const LogRaw &&val) noexcept
 Logging support for data in raw bytes.
template<typename Callable, typename = std::enable_if_t<is_invocable_r<LogStream&, Callable, LogStream&>::value>>
LogStream & operator<< (const Callable &c) noexcept
 Logging support for callable. This gives access to the LogStream instance which e.g. can be used in a loop.
LogStream & operator<< (const LogLevel value) noexcept
 Logging support for LogLevel.

Detailed Description

This class provides the public interface to the logger and is used with the 'IOX2_LOG' macro. In order to add support for custom data types 'operator<<' needs to be implement for the custom type.

{
stream << "MyType { member = " << myType.member << " }";
return stream;
}
This class provides the public interface to the logger and is used with the 'IOX2_LOG' macro....
LogStream & operator<<(const char *cstr) noexcept
Logging support for C-style strings.

Definition at line 189 of file logstream.hpp.

Constructor & Destructor Documentation

◆ LogStream() [1/4]

iox2::legacy::log::LogStream::LogStream ( Logger & logger,
const bb::detail::SourceLocation location,
const LogLevel logLevel )
noexcept

Constructor for a LogStream object with an externally provided logger.

Note
This is not intended for public use! Use the 'IOX2_LOG' macro instead
Parameters
[in]loggerto be used by the LogStream instance
[in]locationthe source location of the log message
[in]logLevelis the log level for the log message

Referenced by LogStream(), LogStream(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator=(), operator=(), and self().

◆ LogStream() [2/4]

iox2::legacy::log::LogStream::LogStream ( const bb::detail::SourceLocation location,
const LogLevel logLevel )
noexcept

Constructor for a LogStream object with the logger from iox2::legacy::log::Logger::get.

Note
This is not intended for public use! Use the 'IOX2_LOG' macro instead
Parameters
[in]locationthe source location of the log message
[in]logLevelis the log level for the log message

◆ ~LogStream()

virtual iox2::legacy::log::LogStream::~LogStream ( )
virtualnoexcept

◆ LogStream() [3/4]

iox2::legacy::log::LogStream::LogStream ( const LogStream & )
delete

References LogStream().

◆ LogStream() [4/4]

iox2::legacy::log::LogStream::LogStream ( LogStream && )
delete

References LogStream().

Member Function Documentation

◆ operator<<() [1/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const bool val)
noexcept

Logging support for 'boolean'.

Parameters
[in]valis the 'boolean' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [2/25]

template<typename Callable, typename = std::enable_if_t<is_invocable_r<LogStream&, Callable, LogStream&>::value>>
LogStream & iox2::legacy::log::LogStream::operator<< ( const Callable & c)
noexcept

Logging support for callable. This gives access to the LogStream instance which e.g. can be used in a loop.

Template Parameters

in] Callable with a signature 'iox2::legacy::log::LogStream&(iox2::legacy::log::LogStream&)'

Parameters
[in]cis the callable which receives a LogStream object for the actual logging
IOX2_LOG(Info, [] (auto& stream) -> auto& {
for(const auto& num: {13, 37, 42, 73}) {
stream << num << " ";
}
return stream;
});
#define IOX2_LOG(level, msg_stream)
Macro for logging.
Definition logging.hpp:63

References LogStream().

◆ operator<<() [3/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const char * cstr)
noexcept

Logging support for C-style strings.

Parameters
[in]cstris the C-style string to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [4/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const char val)
noexcept

Logging support for 'char'.

Parameters
[in]valis the 'char' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [5/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const double val)
noexcept

Logging support for 'double'.

Parameters
[in]valis the 'double' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [6/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const float val)
noexcept

Logging support for 'float'.

Parameters
[in]valis the 'float' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [7/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const int val)
noexcept

Logging support for 'int'.

Parameters
[in]valis the 'int' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [8/25]

template<typename T, typename std::enable_if_t< std::is_integral< T >::value, bool > = 0>
LogStream & iox2::legacy::log::LogStream::operator<< ( const LogBin< T > && val)
noexcept

Logging support for integral numbers in binary format.

Template Parameters

in] T is the integral data type of the value to log

Parameters
[in]valis the value to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [9/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const LogHex< const void *const > && val)
noexcept

Logging support for pointer in hexadecimal format.

Parameters
[in]valis the pointer to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [10/25]

template<typename T, typename std::enable_if_t< std::is_floating_point< T >::value, bool > = 0>
LogStream & iox2::legacy::log::LogStream::operator<< ( const LogHex< T > && val)
noexcept

Logging support for floating point numbers in hexadecimal format.

Template Parameters

in] T is the floating point data type of the value to log

Parameters
[in]valis the value to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [11/25]

template<typename T, typename std::enable_if_t< std::is_integral< T >::value, bool > = 0>
LogStream & iox2::legacy::log::LogStream::operator<< ( const LogHex< T > && val)
noexcept

Logging support for integral numbers in hexadecimal format.

Template Parameters

in] T is the integral data type of the value to log

Parameters
[in]valis the value to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [12/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const LogLevel value)
noexcept

Logging support for LogLevel.

Parameters
[in]valueis the LogLevel to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [13/25]

template<typename T, typename std::enable_if_t< std::is_integral< T >::value, bool > = 0>
LogStream & iox2::legacy::log::LogStream::operator<< ( const LogOct< T > && val)
noexcept

Logging support for integral numbers in octal format.

Template Parameters

in] T is the integral data type of the value to log

Parameters
[in]valis the value to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [14/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const LogRaw && val)
noexcept

Logging support for data in raw bytes.

Parameters
[in]valis the value to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [15/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const long double val)
noexcept

Logging support for 'long double'.

Parameters
[in]valis the 'long double' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [16/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const long long val)
noexcept

Logging support for 'long long'.

Parameters
[in]valis the 'long long' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [17/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const long val)
noexcept

Logging support for 'long'.

Parameters
[in]valis the 'long' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [18/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const short val)
noexcept

Logging support for 'short'.

Parameters
[in]valis the 'short' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [19/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const signed char val)
noexcept

Logging support for 'signed char'.

Parameters
[in]valis the 'signed char' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [20/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const std::string & str)
noexcept

Logging support for std::string.

Parameters
[in]stris the std::string to log
Returns
a reference to the LogStream instance
Todo
iox-#1755 instead of using std::string we could also accept everything with a c_str() method and avoid the std::string dependency; alternatively this could be implemented as free function

References LogStream().

◆ operator<<() [21/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const unsigned char val)
noexcept

Logging support for 'unsigned char'.

Parameters
[in]valis the 'unsigned char' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [22/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const unsigned int val)
noexcept

Logging support for 'unsigned int'.

Parameters
[in]valis the 'unsigned int' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [23/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const unsigned long long val)
noexcept

Logging support for 'unsigned long long'.

Parameters
[in]valis the 'unsigned long long' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [24/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const unsigned long val)
noexcept

Logging support for 'unsigned long'.

Parameters
[in]valis the 'unsigned long' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator<<() [25/25]

LogStream & iox2::legacy::log::LogStream::operator<< ( const unsigned short val)
noexcept

Logging support for 'unsigned short'.

Parameters
[in]valis the 'unsigned short' to log
Returns
a reference to the LogStream instance

References LogStream().

◆ operator=() [1/2]

LogStream & iox2::legacy::log::LogStream::operator= ( const LogStream & )
delete

References LogStream().

◆ operator=() [2/2]

LogStream & iox2::legacy::log::LogStream::operator= ( LogStream && )
delete

References LogStream().

◆ self()

LogStream & iox2::legacy::log::LogStream::self ( )
noexcept

Helper function to convert a r-value reference into a l-value reference in order to be able to extend the data types which can be logged with LogStream object. Without this, one would need to always log a builtin type before a custom type could be logged.

Returns
a reference to the LogStream instance

References LogStream(), and self().

Referenced by self().


The documentation for this class was generated from the following file: