iceoryx2
C++ Language 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
 
LogStreamoperator= (const LogStream &)=delete
 
LogStreamoperator= (LogStream &&)=delete
 
LogStreamself () 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.
 
LogStreamoperator<< (const char *cstr) noexcept
 Logging support for C-style strings.
 
LogStreamoperator<< (const std::string &str) noexcept
 Logging support for std::string.
 
LogStreamoperator<< (const bool val) noexcept
 Logging support for 'boolean'.
 
LogStreamoperator<< (const char val) noexcept
 Logging support for 'char'.
 
LogStreamoperator<< (const signed char val) noexcept
 Logging support for 'signed char'.
 
LogStreamoperator<< (const unsigned char val) noexcept
 Logging support for 'unsigned char'.
 
LogStreamoperator<< (const short val) noexcept
 Logging support for 'short'.
 
LogStreamoperator<< (const unsigned short val) noexcept
 Logging support for 'unsigned short'.
 
LogStreamoperator<< (const int val) noexcept
 Logging support for 'int'.
 
LogStreamoperator<< (const unsigned int val) noexcept
 Logging support for 'unsigned int'.
 
LogStreamoperator<< (const long val) noexcept
 Logging support for 'long'.
 
LogStreamoperator<< (const unsigned long val) noexcept
 Logging support for 'unsigned long'.
 
LogStreamoperator<< (const long long val) noexcept
 Logging support for 'long long'.
 
LogStreamoperator<< (const unsigned long long val) noexcept
 Logging support for 'unsigned long long'.
 
LogStreamoperator<< (const float val) noexcept
 Logging support for 'float'.
 
LogStreamoperator<< (const double val) noexcept
 Logging support for 'double'.
 
LogStreamoperator<< (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>
LogStreamoperator<< (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>
LogStreamoperator<< (const LogHex< T > &&val) noexcept
 Logging support for floating point numbers in hexadecimal format.
 
LogStreamoperator<< (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>
LogStreamoperator<< (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>
LogStreamoperator<< (const LogBin< T > &&val) noexcept
 Logging support for integral numbers in binary format.
 
LogStreamoperator<< (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>>
LogStreamoperator<< (const Callable &c) noexcept
 Logging support for callable. This gives access to the LogStream instance which e.g. can be used in a loop.
 
LogStreamoperator<< (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.
constexpr bool always_false_v
Helper value to bind a static_assert to a type.

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

◆ 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

◆ LogStream() [4/4]

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

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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ operator<<() [10/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

◆ operator<<() [11/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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ 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

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