Ocean
Ocean::Log Class Reference

This class provides access to three different Message objects, e.g., for regular information, warnings, or errors. More...

Data Structures

struct  StreamHelper
 Helper class allowing to specify a specific message object or stream type. More...
 

Public Types

typedef Ocean::MessageObject< Messenger::isActive()> MessageObject
 Definition of a default message object, only active if Messenger::isActive() == true. More...
 
typedef Ocean::MessageObject< Messenger::isActive() &&Messenger::isDebugBuild()> DebugMessageObject
 Definition of a debug message object, only active on debug builds and if Messenger::isActive() == true. More...
 

Static Public Member Functions

static DebugMessageObject debug ()
 Returns the message for debug messages. More...
 
static MessageObject info ()
 Returns the message for information messages. More...
 
static MessageObject warning ()
 Returns the message for warning messages. More...
 
static MessageObject error ()
 Returns the message for error messages. More...
 
template<typename T , typename TStream = MessageObject>
static constexpr bool isSupported ()
 Returns whether a specific data type can be written to a message object (or an arbitrary stream). More...
 

Detailed Description

This class provides access to three different Message objects, e.g., for regular information, warnings, or errors.

Member Typedef Documentation

◆ DebugMessageObject

Definition of a debug message object, only active on debug builds and if Messenger::isActive() == true.

◆ MessageObject

Definition of a default message object, only active if Messenger::isActive() == true.

Member Function Documentation

◆ debug()

Log::DebugMessageObject Ocean::Log::debug ( )
inlinestatic

Returns the message for debug messages.

Debug messages do not show up on release builds.
The debug log is intended to simplify code like this:

#ifdef OCEAN_DEBUG
info() << "<debug> This message shows up on debug builds only."
#endif
static MessageObject info()
Returns the message for information messages.
Definition: Messenger.h:1064
Returns
The message object that will be stripped away on release builds

◆ error()

Log::MessageObject Ocean::Log::error ( )
inlinestatic

Returns the message for error messages.

Returns
The message object

◆ info()

Log::MessageObject Ocean::Log::info ( )
inlinestatic

Returns the message for information messages.

Returns
The message object

◆ isSupported()

template<typename T , typename TStream >
constexpr bool Ocean::Log::isSupported
staticconstexpr

Returns whether a specific data type can be written to a message object (or an arbitrary stream).

The function returns whether the shift operator of MessageObject (or of an arbitrary stream) supports the specified data type. Usage:

void function()
{
int value = 9;
if constexpr (Log::isSupported<int>())
{
Log::info() << "Value is: " << value;
}
else
{
Log::info() << "Value cannot be written to log.";
}
}
Returns
True, if so
Template Parameters
TThe data type to be checked
TStreamThe data type of the message object (or stream) to be checked

◆ warning()

Log::MessageObject Ocean::Log::warning ( )
inlinestatic

Returns the message for warning messages.

Returns
The message object

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