AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
slic_macros.hpp File Reference
#include "axom/config.hpp"
#include "axom/core/Macros.hpp"

Classes

struct  axom::slic::detail::FalseType
 Variable of a type that evaluates as false. More...
 

Namespaces

 axom
 
 axom::slic
 
 axom::slic::detail
 

Macros

#define SLIC_INFO(msg)
 Logs an Info message. More...
 
#define SLIC_INFO_TAGGED(msg, tag)
 Logs an Info message to a tagged stream. More...
 
#define SLIC_INFO_IF(EXP, msg)
 Logs an Info message iff EXP is true. More...
 
#define SLIC_INFO_ROOT(msg)   SLIC_INFO_IF(axom::slic::isRoot(), msg)
 Logs an Info message if on root. More...
 
#define SLIC_INFO_ROOT_IF(EXP, msg)   SLIC_INFO_IF((EXP) && (axom::slic::isRoot()), msg)
 Logs an Info message if on root and iff EXP is true. More...
 
#define SLIC_DEBUG(msg)
 Logs a Debug message. More...
 
#define SLIC_DEBUG_IF(EXP, msg)
 Logs an Debug message iff EXP is true. More...
 
#define SLIC_DEBUG_ROOT(msg)   SLIC_DEBUG_IF(axom::slic::isRoot(), msg)
 Logs a Debug message if on root. More...
 
#define SLIC_DEBUG_ROOT_IF(EXP, msg)   SLIC_DEBUG_IF((EXP) && (axom::slic::isRoot()), msg)
 Logs a Debug message if on root and iff EXP is true. More...
 
#define SLIC_DEBUG_PRINT_CONTAINER(name, container)
 Logs a Debug message containing the contents of the container, moving the contents to the host if needed. More...
 
SLIC_ERROR MACROS
Attention
These error macros are collective operations. All ranks in the user-supplied communicator must call the macro when used within an MPI distributed environment, and slic::enableAbortOnError() is called for the current active logger (default is enabled for loggers)
See also
axom::slic::isAbortOnErrorsEnabled()
axom::slic::setAbortOnError(bool status)
#define SLIC_ERROR(msg)
 Logs an error and aborts the application. More...
 
#define SLIC_ERROR_IF(EXP, msg)
 Logs an error iff EXP is true and aborts the application. More...
 
#define SLIC_ERROR_ROOT(msg)
 Macro that logs given error message only on root. More...
 
#define SLIC_ERROR_ROOT_IF(EXP, msg)
 Macro that logs given error message only on root iff EXP is true. More...
 
SLIC_WARNING MACROS
Attention
These warning macros can be set as collective operations. These warning macros are collective if slic::enableAbortOnWarning() is called for the current active logger (default is disabled for loggers). These warning macros must then be called by all ranks in the user-supplied communicator when used within an MPI distributed environment.
See also
axom::slic::isAbortOnWarningsEnabled()
axom::slic::setAbortOnWarning(bool status)
#define SLIC_WARNING(msg)
 Logs a warning message. More...
 
#define SLIC_WARNING_IF(EXP, msg)
 Logs a warning iff EXP is true. More...
 
#define SLIC_WARNING_ROOT(msg)
 Macro that logs given warning message only on root. More...
 
#define SLIC_WARNING_ROOT_IF(EXP, msg)
 Macro that logs given warning message only on root iff EXP is true. More...
 
SLIC_ASSERT MACROS
Attention
These assert macros are collective operations. All ranks in the user-supplied communicator must call the macro when used within an MPI distributed environment, and slic::enableAbortOnError() is called for the current active logger (default is enabled for loggers)
See also
axom::slic::isAbortOnErrorsEnabled()
axom::slic::setAbortOnError(bool status)
#define SLIC_ASSERT(EXP)
 Asserts that a given expression is true. If the expression is not true an error will be logged and the application will be aborted. More...
 
#define SLIC_ASSERT_MSG(EXP, msg)
 Same as SLIC_ASSERT, but with a custom error message. More...
 
SLIC_CHECK MACROS
Attention
These check macros can be set as collective operations. These check macros are collective if either:
  • slic::debug::checksAreErrors is set to true (default is false) and slic::enableAbortOnError() is called for the current active logger (default is enabled for loggers)
  • slic::debug::checksAreErrors is set to false (default is false) and slic::enableAbortOnWarning() is called for the current active logger (default is disabled for loggers)

These check macros must then be called by all ranks in the user-supplied communicator when used within an MPI distributed environment.

See also
axom::slic::isAbortOnErrorsEnabled()
axom::slic::setAbortOnError(bool status)
axom::slic::isAbortOnWarningsEnabled()
axom::slic::setAbortOnWarning(bool status)
#define SLIC_CHECK(EXP)
 Checks that a given expression is true. If the expression is not true a warning is logged, but, in contrast to the similar SLIC_ASSERT macro the application is not aborted. More...
 
#define SLIC_CHECK_MSG(EXP, msg)
 Same as SLIC_CHECK, but with a custom error message. More...
 

Variables

static const FalseType axom::slic::detail::false_value
 

Macro Definition Documentation

◆ SLIC_ERROR

#define SLIC_ERROR (   msg)
Value:
do \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logErrorMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
static const FalseType false_value
Definition: slic_macros.hpp:755
void abort()
Calls abort function. Default is abort() or MPI_Abort() in a MPI distributed environment.
bool isAbortOnErrorsEnabled()
Checks whether aborts on errors are enabled for the current logger.
void logErrorMessage(const std::string &message, const std::string &fileName, int line)
Convenience method to log an error message.

Logs an error and aborts the application.

Parameters
[in]msguser-supplied message
Warning
This macro calls processAbort().
Note
The SLIC_ERROR macro is always active.

Usage:

SLIC_ERROR( "my_val should always be positive" );
#define SLIC_ERROR(msg)
Logs an error and aborts the application.
Definition: slic_macros.hpp:45

◆ SLIC_ERROR_IF

#define SLIC_ERROR_IF (   EXP,
  msg 
)
Value:
do \
{ \
if(EXP) \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logErrorMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \

Logs an error iff EXP is true and aborts the application.

Parameters
[in]EXPuser-supplied boolean expression.
[in]msguser-supplied message.
Warning
This macro calls processAbort() iff EXP is true.
Note
The SLIC_ERROR_IF macro is always active.

Usage:

SLIC_ERROR_IF( (val < 0), "my_val should always be positive" );
#define SLIC_ERROR_IF(EXP, msg)
Logs an error iff EXP is true and aborts the application.
Definition: slic_macros.hpp:73

◆ SLIC_ERROR_ROOT

#define SLIC_ERROR_ROOT (   msg)
Value:
do \
{ \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logErrorMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \
bool isRoot()
Checks if we are on the root rank. Used for selective logging on root nodes.

Macro that logs given error message only on root.

Parameters
[in]msguser-supplied message.
Warning
This macro calls processAbort() iff EXP is true.
Note
The SLIC_ERROR_ROOT macro is always active.
By default, all ranks are considered to be root. Must call axom::slic::initialize(is_root={true|false}) or set via axom::slic::setIsRoot({true|false}) to filter based on root.

Usage:

SLIC_ERROR_ROOT( "An error has occurred!" );
#define SLIC_ERROR_ROOT(msg)
Macro that logs given error message only on root.
Definition: slic_macros.hpp:106

◆ SLIC_ERROR_ROOT_IF

#define SLIC_ERROR_ROOT_IF (   EXP,
  msg 
)
Value:
do \
{ \
if(EXP) \
{ \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logErrorMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \
} \

Macro that logs given error message only on root iff EXP is true.

Parameters
[in]EXPuser-supplied boolean expression.
[in]msguser-supplied message.
Note
The SLIC_ERROR_ROOT_IF macro is always active.
By default, all ranks are considered to be root. Must call axom::slic::initialize(is_root={true|false}) or set via axom::slic::setIsRoot({true|false}) to filter based on root.

Usage:

SLIC_ERROR_ROOT_IF( (my_val < 0), "my_val should always be positive" );
#define SLIC_ERROR_ROOT_IF(EXP, msg)
Macro that logs given error message only on root iff EXP is true.
Definition: slic_macros.hpp:139

◆ SLIC_WARNING

#define SLIC_WARNING (   msg)
Value:
do \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logWarningMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
bool isAbortOnWarningsEnabled()
Checks whether aborts on warnings are enabled for the current logger.
void logWarningMessage(const std::string &message, const std::string &fileName, int line)
Convenience method to log warning messages.

Logs a warning message.

Parameters
[in]msguser-supplied message
Note
The SLIC_WARNING macro is always active.
Aborts the application when slic::enableAbortOnWarning()

Usage:

SLIC_WARNING( "my_val should always be positive" );
#define SLIC_WARNING(msg)
Logs a warning message.
Definition: slic_macros.hpp:190

◆ SLIC_WARNING_IF

#define SLIC_WARNING_IF (   EXP,
  msg 
)
Value:
do \
{ \
if(EXP) \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logWarningMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \

Logs a warning iff EXP is true.

Parameters
[in]EXPuser-supplied boolean expression.
[in]msguser-supplied message.
Note
The SLIC_WARNING_IF macro is always active.
Aborts the application when slic::enableAbortOnWarning()

Usage:

SLIC_WARNING_IF( (val < 0), "my_val should always be positive" );
#define SLIC_WARNING_IF(EXP, msg)
Logs a warning iff EXP is true.
Definition: slic_macros.hpp:218

◆ SLIC_WARNING_ROOT

#define SLIC_WARNING_ROOT (   msg)
Value:
do \
{ \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logWarningMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \

Macro that logs given warning message only on root.

Parameters
[in]msguser-supplied message.
Note
The SLIC_WARNING_ROOT macro is always active.
By default, all ranks are considered to be root. Must call axom::slic::initialize(is_root={true|false}) or set via axom::slic::setIsRoot({true|false}) to filter based on root.

Usage:

SLIC_WARNING_ROOT( "A warning has occurred!" );
#define SLIC_WARNING_ROOT(msg)
Macro that logs given warning message only on root.
Definition: slic_macros.hpp:250

◆ SLIC_WARNING_ROOT_IF

#define SLIC_WARNING_ROOT_IF (   EXP,
  msg 
)
Value:
do \
{ \
if(EXP) \
{ \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logWarningMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \
} \

Macro that logs given warning message only on root iff EXP is true.

Parameters
[in]EXPuser-supplied boolean expression.
[in]msguser-supplied message.
Note
The SLIC_WARNING_ROOT_IF macro is always active.
By default, all ranks are considered to be root. Must call axom::slic::initialize(is_root={true|false}) or set via axom::slic::setIsRoot({true|false}) to filter based on root.

Usage:

SLIC_WARNING_ROOT_IF( (val < 0), "my_val should always be positive" );
#define SLIC_WARNING_ROOT_IF(EXP, msg)
Macro that logs given warning message only on root iff EXP is true.
Definition: slic_macros.hpp:283

◆ SLIC_ASSERT

#define SLIC_ASSERT (   EXP)
Value:
do \
{ \
if(!(EXP)) \
{ \
std::ostringstream __oss; \
__oss << "Failed Assert: " << #EXP; \
axom::slic::logErrorMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \

Asserts that a given expression is true. If the expression is not true an error will be logged and the application will be aborted.

Parameters
[in]EXPuser-supplied boolean expression.
Warning
This macro calls processAbort() iff EXP is false.
Note
This macro is only active when AXOM_DEBUG is defined.

Usage:

SLIC_ASSERT( my_val >= 0 );
#define SLIC_ASSERT(EXP)
Asserts that a given expression is true. If the expression is not true an error will be logged and th...
Definition: slic_macros.hpp:337

◆ SLIC_ASSERT_MSG

#define SLIC_ASSERT_MSG (   EXP,
  msg 
)
Value:
do \
{ \
if(!(EXP)) \
{ \
std::ostringstream __oss; \
__oss << "Failed Assert: " << #EXP << std::endl << msg; \
axom::slic::logErrorMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \

Same as SLIC_ASSERT, but with a custom error message.

Parameters
[in]EXPuser-supplied boolean expression.
[in]msguser-supplied message
Warning
This macro calls processAbort() iff EXP is false.
Note
This macro is only active when AXOM_DEBUG is defined.
See also
SLIC_ASSERT( EXP )

Usage:

SLIC_ASSERT_MSG( my_val >= 0, "my_val must always be positive" );
#define SLIC_ASSERT_MSG(EXP, msg)
Same as SLIC_ASSERT, but with a custom error message.
Definition: slic_macros.hpp:369

◆ SLIC_CHECK

#define SLIC_CHECK (   EXP)
Value:
do \
{ \
if(!(EXP)) \
{ \
std::ostringstream __oss; \
__oss << "Failed Check: " << #EXP; \
{ \
axom::slic::logErrorMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \
else \
{ \
axom::slic::logWarningMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \
} \
static AXOM_SLIC_EXPORT bool checksAreErrors
Definition: slic.hpp:34

Checks that a given expression is true. If the expression is not true a warning is logged, but, in contrast to the similar SLIC_ASSERT macro the application is not aborted.

Parameters
[in]EXPuser-supplied boolean expression.
Note
This macro is only active when AXOM_DEBUG is defined.

Usage:

SLIC_CHECK( my_val >= 0 );
#define SLIC_CHECK(EXP)
Checks that a given expression is true. If the expression is not true a warning is logged,...
Definition: slic_macros.hpp:425

◆ SLIC_CHECK_MSG

#define SLIC_CHECK_MSG (   EXP,
  msg 
)
Value:
do \
{ \
if(!(EXP)) \
{ \
std::ostringstream __oss; \
__oss << "Failed Check: " << #EXP << std::endl << msg; \
{ \
axom::slic::logErrorMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \
else \
{ \
axom::slic::logWarningMessage(__oss.str(), __FILE__, __LINE__); \
{ \
} \
} \
} \

Same as SLIC_CHECK, but with a custom error message.

Parameters
[in]EXPuser-supplied boolean expression.
[in]msguser-supplied message
Note
This macro is only active when AXOM_DEBUG is defined.
See also
SLIC_DEBUG( EXP )

Usage:

SLIC_CHECK_MSG( my_val >= 0, "my_val must always be positive" );
#define SLIC_CHECK_MSG(EXP, msg)
Same as SLIC_CHECK, but with a custom error message.
Definition: slic_macros.hpp:467

◆ SLIC_INFO

#define SLIC_INFO (   msg)
Value:
do \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logMessage(axom::slic::message::Info, __oss.str(), __FILE__, __LINE__); \
@ Info
INFO log information that is useful for users & developers.
Definition: MessageLevel.hpp:37
void logMessage(message::Level level, const std::string &message, bool filter_duplicates=false)
Logs the given message to all registered streams.

Logs an Info message.

Parameters
[in]msguser-supplied message
Note
The SLIC_INFO macro is always active.

Usage:

SLIC_INFO( "informative text goes here" );
#define SLIC_INFO(msg)
Logs an Info message.
Definition: slic_macros.hpp:527

◆ SLIC_INFO_TAGGED

#define SLIC_INFO_TAGGED (   msg,
  tag 
)
Value:
do \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logMessage(axom::slic::message::Info, __oss.str(), tag, __FILE__, __LINE__, false, true); \

Logs an Info message to a tagged stream.

Parameters
[in]msguser-supplied message
[in]taguser-supplied tag
Note
The SLIC_INFO_TAGGED macro is always active.

Usage:

SLIC_INFO_TAGGED("informative text goes here", "tag");
#define SLIC_INFO_TAGGED(msg, tag)
Logs an Info message to a tagged stream.
Definition: slic_macros.hpp:550

◆ SLIC_INFO_IF

#define SLIC_INFO_IF (   EXP,
  msg 
)
Value:
do \
{ \
if(EXP) \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logMessage(axom::slic::message::Info, __oss.str(), __FILE__, __LINE__); \
} \

Logs an Info message iff EXP is true.

Parameters
[in]EXPuser-supplied boolean expression.
[in]msguser-supplied message.
Note
The SLIC_INFO_IF macro is always active.

Usage:

SLIC_INFO_IF( (val < 0), "my_val should always be positive" );
#define SLIC_INFO_IF(EXP, msg)
Logs an Info message iff EXP is true.
Definition: slic_macros.hpp:573

◆ SLIC_INFO_ROOT

#define SLIC_INFO_ROOT (   msg)    SLIC_INFO_IF(axom::slic::isRoot(), msg)

Logs an Info message if on root.

Parameters
[in]msguser-supplied message.
Note
The SLIC_INFO_ROOT macro is always active.

Usage:

SLIC_INFO_ROOT( "informative text goes here" );
#define SLIC_INFO_ROOT(msg)
Logs an Info message if on root.
Definition: slic_macros.hpp:598

◆ SLIC_INFO_ROOT_IF

#define SLIC_INFO_ROOT_IF (   EXP,
  msg 
)    SLIC_INFO_IF((EXP) && (axom::slic::isRoot()), msg)

Logs an Info message if on root and iff EXP is true.

Parameters
[in]EXPuser-supplied boolean expression.
[in]msguser-supplied message.
Note
The SLIC_INFO_ROOT_IF macro is always active.

Usage:

SLIC_INFO_ROOT_IF( (val < 0), "my_val should always be positive" );
#define SLIC_INFO_ROOT_IF(EXP, msg)
Logs an Info message if on root and iff EXP is true.
Definition: slic_macros.hpp:615

◆ SLIC_DEBUG

#define SLIC_DEBUG (   msg)
Value:
do \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logMessage(axom::slic::message::Debug, __oss.str(), __FILE__, __LINE__); \
@ Debug
DEBUG log information that is useful for developers.
Definition: MessageLevel.hpp:38

Logs a Debug message.

Parameters
[in]msguser-supplied message
Note
The SLIC_Debug macro is active when AXOM_DEBUG is defined.

Usage:

SLIC_DEBUG( "debug message goes here" );
#define SLIC_DEBUG(msg)
Logs a Debug message.
Definition: slic_macros.hpp:633

◆ SLIC_DEBUG_IF

#define SLIC_DEBUG_IF (   EXP,
  msg 
)
Value:
do \
{ \
if(EXP) \
{ \
std::ostringstream __oss; \
__oss << msg; \
axom::slic::logMessage(axom::slic::message::Debug, __oss.str(), __FILE__, __LINE__); \
} \

Logs an Debug message iff EXP is true.

Parameters
[in]EXPuser-supplied boolean expression.
[in]msguser-supplied message.
Note
The SLIC_DEBUG_IF macro is active when AXOM_DEBUG is defined.

Usage:

SLIC_DEBUG_IF( (val < 0), "my_val should always be positive" );
#define SLIC_DEBUG_IF(EXP, msg)
Logs an Debug message iff EXP is true.
Definition: slic_macros.hpp:656

◆ SLIC_DEBUG_ROOT

#define SLIC_DEBUG_ROOT (   msg)    SLIC_DEBUG_IF(axom::slic::isRoot(), msg)

Logs a Debug message if on root.

Parameters
[in]msguser-supplied message.
Note
The SLIC_DEBUG_ROOT macro is active when AXOM_DEBUG is defined.

Usage:

SLIC_DEBUG_ROOT( "informative text goes here" );
#define SLIC_DEBUG_ROOT(msg)
Logs a Debug message if on root.
Definition: slic_macros.hpp:681

◆ SLIC_DEBUG_ROOT_IF

#define SLIC_DEBUG_ROOT_IF (   EXP,
  msg 
)    SLIC_DEBUG_IF((EXP) && (axom::slic::isRoot()), msg)

Logs a Debug message if on root and iff EXP is true.

Parameters
[in]EXPuser-supplied boolean expression.
[in]msguser-supplied message.
Note
The SLIC_DEBUG_ROOT_IF macro is active when AXOM_DEBUG is defined.

Usage:

SLIC_DEBUG_ROOT_IF( (val < 0), "my_val should always be positive" );
#define SLIC_DEBUG_ROOT_IF(EXP, msg)
Logs a Debug message if on root and iff EXP is true.
Definition: slic_macros.hpp:698

◆ SLIC_DEBUG_PRINT_CONTAINER

#define SLIC_DEBUG_PRINT_CONTAINER (   name,
  container 
)
Value:
do \
{ \
std::ostringstream __oss; \
axom::slic::detail::printContainer(__oss, name, container); \
axom::slic::logMessage(axom::slic::message::Debug, __oss.str(), __FILE__, __LINE__); \
void printContainer(std::ostream &os, const std::string &name, const ContainerType &container)
Print a container to a stream, moving the data to the host, if needed.
Definition: slic.hpp:539

Logs a Debug message containing the contents of the container, moving the contents to the host if needed.

Parameters
[in]nameThe name of the container in the printed message.
[in]containerThe container (array, vector, view).
Note
The SLIC_DEBUG_PRINT_CONTAINER macro is active when AXOM_DEBUG is defined.

Usage:

SLIC_DEBUG_PRINT_CONTAINER( "dataView", dataView );
Provides a view over a generic array container.
Definition: ArrayView.hpp:47
#define SLIC_DEBUG_PRINT_CONTAINER(name, container)
Logs a Debug message containing the contents of the container, moving the contents to the host if nee...
Definition: slic_macros.hpp:717