MeVisLabToolboxReference
Logging Macros

Macros that can be used for logging of errors/warnings and information strings. More...

Macros to print debug information.

#define mlDebugConst(ENV_VAR, COUTS)   _mlDebugConst(ENV_VAR, COUTS)
 Public macro to be used instead of print debug information. More...
 
#define mlDebug(COUTS)
 This macro prints debug information given by COUTS. More...
 
#define mlDebugConditional(COND_SYM, COUTS)
 Macro to specify subsets of debug outputs for a debug symbol which is given by the runtime type of the class. More...
 
#define mlDebugPrint(COUTS)   _mlDebugConst(ML_DEBUG_ENV_NAME, COUTS)
 Macro for printing debug information. More...
 
#define mlDebugClass(CLASS_NAME, COUTS)
 Macro for printing debug information. More...
 

Public macros to handle (fatal) errors, warnings, information and trace log information.

#define ML_PRINT_FATAL_ERROR(FUNC_NAME, REASON, HANDLING)   _ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, NULL, NULL)
 Like ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped. More...
 
#define ML_PRINT_ERROR(FUNC_NAME, REASON, HANDLING)   _ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, NULL, NULL)
 Like ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped. More...
 
#define ML_PRINT_WARNING(FUNC_NAME, REASON, HANDLING)   _ML_PRINT_WARNING_DUMP(FUNC_NAME, REASON, HANDLING, NULL, NULL)
 Like ML_PRINT_WARNING_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped. More...
 
#define ML_PRINT_INFORMATION(FUNC_NAME, REASON, HANDLING)   _ML_PRINT_INFORMATION_DUMP(FUNC_NAME, REASON, HANDLING, NULL, NULL)
 Like ML_PRINT_INFORMATION_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped. More...
 
#define ML_PRINT_INFO(FUNC_NAME, HANDLING)   _ML_PRINT_INFORMATION_DUMP(FUNC_NAME, ML_RESULT_OK, HANDLING, NULL, NULL)
 Convenience version of ML_PRINT_INFORMATION(FUNC_NAME, REASON, HANDLING) with REASON = ML_RESULT_OK. More...
 

Public macros for logging errors, warnings and information messages

Each of the macros returns an ostream which allows to pipe additional details into the message.

These macros are equivalent to the older ML_PRINT_* macros which only took a string for the message details. The error code is an optional second argument. If it is omitted, ML_BAD_PARAMETER is used.

Example:

if (outIndex<0) {
mlError("SomeClass::SomeMethod", ML_BAD_PARAMETER) << "returning NULL, excepted outIndex>=0, but got outIndex==" << outIndex;
}
if (outIndex>3) {
mlError("SomeClass::SomeMethod") << "returning NULL, excepted outIndex<=3, but got outIndex==" << outIndex;
}
#define mlFatalError(FUNCTION, ...)   ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_FATAL, ML_NAMESPACE::internal::LogCollector::getErrorCode(__VA_ARGS__) ,FUNCTION).getStream()
 Logs a fatal error for FUNCTION with optional MLErrorCode. More...
 
#define mlError(FUNCTION, ...)   ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_ERROR, ML_NAMESPACE::internal::LogCollector::getErrorCode(__VA_ARGS__) , FUNCTION).getStream()
 Logs an error for FUNCTION with optional MLErrorCode. More...
 
#define mlWarning(FUNCTION, ...)   ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_WARNING, ML_NAMESPACE::internal::LogCollector::getErrorCode(__VA_ARGS__) , FUNCTION).getStream()
 Logs a warning for FUNCTION with optional MLErrorCode. More...
 
#define mlInfo(FUNCTION)   ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_INFORMATION, ML_RESULT_OK, FUNCTION).getStream()
 Logs an informational message. More...
 
#define mlFatalErrorWithDump(FUNCTION, ERRORCODE, OBJECT)   ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_FATAL, ERRORCODE, FUNCTION, (OBJECT), ML_NAMESPACE::internal::MLSecureGetRuntimeTypeId((OBJECT))).getStream()
 Logs a fatal error for FUNCTION with MLErrorCode ERRORCODE and additionally dumps the given OBJECT (which needs to support getTypeId()). More...
 
#define mlErrorWithDump(FUNCTION, ERRORCODE, OBJECT)   ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_ERROR, ERRORCODE, FUNCTION, (OBJECT), ML_NAMESPACE::internal::MLSecureGetRuntimeTypeId((OBJECT))).getStream()
 Logs an error for FUNCTION with MLErrorCode ERRORCODE and additionally dumps the given OBJECT (which needs to support getTypeId()). More...
 
#define mlWarningWithDump(FUNCTION, ERRORCODE, OBJECT)   ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_WARNING, ERRORCODE, FUNCTION, (OBJECT), ML_NAMESPACE::internal::MLSecureGetRuntimeTypeId((OBJECT))).getStream()
 Logs a warning for FUNCTION with MLErrorCode ERRORCODE and additionally dumps the given OBJECT (which needs to support getTypeId()). More...
 
#define mlInfoWithDump(FUNCTION, OBJECT)   ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_INFORMATION, ML_RESULT_OK, FUNCTION, (OBJECT), ML_NAMESPACE::internal::MLSecureGetRuntimeTypeId((OBJECT))).getStream()
 Logs an informational message for FUNCTION and additionally dumps the given OBJECT (which needs to support getTypeId()). More...
 

Detailed Description

Macros that can be used for logging of errors/warnings and information strings.

Macro Definition Documentation

◆ ML_PRINT_ERROR

#define ML_PRINT_ERROR (   FUNC_NAME,
  REASON,
  HANDLING 
)    _ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, NULL, NULL)

Like ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped.

Have a look at mlError for new style logging.

Definition at line 444 of file mlErrorMacros.h.

Referenced by __ML_KERNEL_CASE_CODE_clearAndHandleError(), ml::TVirtualVolume< DATATYPE >::_init(), ml::ITKMLBaseWrapper< OBJ_TYPE, OBJ_TYPE_POINTER, WRAPPER_CLASS_NAME >::addInputBaseField(), ml::VTKMLBaseWrapper< OBJ_TYPE, OBJ_TYPE_POINTER, WRAPPER_CLASS_NAME >::addInputBaseField(), ml::ITKMLBaseWrapper< OBJ_TYPE, OBJ_TYPE_POINTER, WRAPPER_CLASS_NAME >::addOutputBaseField(), ml::VTKMLBaseWrapper< OBJ_TYPE, OBJ_TYPE_POINTER, WRAPPER_CLASS_NAME >::addOutputBaseField(), ml::PCLSupportTools::appendFillPattern(), ml::PCLMLTools::appendSubImageVoxelsToPointCloud(), ml::TQuaternion< DT >::arg(), ml::PCLMLTools::createPointCloudFromBaseList(), ml::TQuaternion< DT >::div(), ml::TQuaternion< DT >::getAsMat4(), ml::getInputAsItkImportImageAndSubImg(), ml::omIDTypeT< char >::getInt(), ml::Tmat2< MLdouble >::inverse(), ml::TQuaternion< DT >::inverse(), ml::FloatingPointMatrix< Tvec2< MLdouble >, 2 >::linearIndexed(), ml::FloatingPointMatrix< Tvec2< MLdouble >, 2 >::linearIndexedConst(), ml::TKernel< KernelDataType >::manipulateKernelElements(), ML_ITK_ML_PRINT_ERROR(), ml::MLInverseMatHelper(), ml::mul_mv(), ml::TQuaternion< DT >::normalize(), ml::omIDTypeT< char >::omIDTypeT(), ml::operator*(), ml::FloatingPointMatrix< Tvec2< MLdouble >, 2 >::operator[](), ml::ListTemplate< vec4i >::readStateFromTree(), ml::BaseListTemplate< XMarker >::readStateFromTree(), ml::PCLInventorTools::setMFVecFromPointCloud(), ml::setMLWorldFromITKScaleOriginAndOrientation(), ml::ListTemplate< vec4i >::setPersistentState(), ml::TQuaternion< DT >::sqrt(), MLTimer::start(), MLTimer::stop(), and ml::Tvec3< MLdouble >::Tvec3().

◆ ML_PRINT_FATAL_ERROR

◆ ML_PRINT_INFO

#define ML_PRINT_INFO (   FUNC_NAME,
  HANDLING 
)    _ML_PRINT_INFORMATION_DUMP(FUNC_NAME, ML_RESULT_OK, HANDLING, NULL, NULL)

Convenience version of ML_PRINT_INFORMATION(FUNC_NAME, REASON, HANDLING) with REASON = ML_RESULT_OK.

Have a look at mlInfo for new style logging.

Definition at line 470 of file mlErrorMacros.h.

◆ ML_PRINT_INFORMATION

#define ML_PRINT_INFORMATION (   FUNC_NAME,
  REASON,
  HANDLING 
)    _ML_PRINT_INFORMATION_DUMP(FUNC_NAME, REASON, HANDLING, NULL, NULL)

Like ML_PRINT_INFORMATION_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped.

Have a look at mlInfo for new style logging.

Definition at line 462 of file mlErrorMacros.h.

◆ ML_PRINT_WARNING

#define ML_PRINT_WARNING (   FUNC_NAME,
  REASON,
  HANDLING 
)    _ML_PRINT_WARNING_DUMP(FUNC_NAME, REASON, HANDLING, NULL, NULL)

◆ mlDebug

#define mlDebug (   COUTS)

This macro prints debug information given by COUTS.

It requires that the class has the runtime type system implemented. So it accesses the type id and creates the debug symbol by using 'ML_' + the class name. This is the normal macro used in implementations of ML modules. See header documentation for more information about debug printing.

Parameters
COUTSThe stream output redirected to the MLErrorOutput instance if the corresponding debug symbol is activated.

Definition at line 126 of file mlDebug.h.

◆ mlDebugClass

#define mlDebugClass (   CLASS_NAME,
  COUTS 
)

Macro for printing debug information.

It requires that the class CLASS_NAME has the runtime type system implemented. So it accesses the type id and creates debug environment name. See header documentation for more information about debug printing.

Parameters
CLASS_NAMEThe class type used to generate the debug symbol on which the output of COUTS is activated.
COUTSThe stream output sent to the error/debug output if the debug symbol created from CLASS_NAME is activated.

Definition at line 200 of file mlDebug.h.

◆ mlDebugConditional

#define mlDebugConditional (   COND_SYM,
  COUTS 
)

Macro to specify subsets of debug outputs for a debug symbol which is given by the runtime type of the class.

It prints debug information in two different cases:

  • If the class name (given by the runtime type) is specified as symbol or
  • If the class name + "-" + COND_SYM is specified.

E.g., if the following macro is used in the class "MyModule":

mlDebugConditional("CASES", "Message1");

the debug information "Message1" is printed if the debug symbol "ML_MYMODULE" is defined or if the the debug symbol "ML_MYMODULE-CASES" is specified. If only "ML_MYMODULE-CASES" is specified then only "Message1" is printed but nothing else from class MyModule.

This macro requires that the class in which it is used has the runtime type system implemented. So it accesses the type id and creates debug environment name from it. See header documentation for more information about debug printing.

Parameters
COND_SYMspecifies the additional symbol added to the class symbol (separated by a "-")
COUTSThe stream output sent to the error/debug output if the symbol given by the class name + "-" + COND_SYM is activated.

Definition at line 168 of file mlDebug.h.

◆ mlDebugConst

#define mlDebugConst (   ENV_VAR,
  COUTS 
)    _mlDebugConst(ENV_VAR, COUTS)

Public macro to be used instead of print debug information.

See header documentation of this file for full documentation.

Definition at line 106 of file mlDebug.h.

◆ mlDebugPrint

#define mlDebugPrint (   COUTS)    _mlDebugConst(ML_DEBUG_ENV_NAME, COUTS)

Macro for printing debug information.

It uses the ML_DEBUG_ENV_VAR as name of the class to be debugged. ML_DEBUG_ENV_VAR is required to be defined. Useful for classes which do not have a runtime interface. See header documentation for more information about debug printing.

Parameters
COUTSThe stream output sent to the error/debug output if the symbol defined in ML_DEBUG_ENV_NAME is activated.

Definition at line 180 of file mlDebug.h.

◆ mlError

#define mlError (   FUNCTION,
  ... 
)    ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_ERROR, ML_NAMESPACE::internal::LogCollector::getErrorCode(__VA_ARGS__) , FUNCTION).getStream()

Logs an error for FUNCTION with optional MLErrorCode.

If MLErrorCode is omitted, ML_BAD_PARAMETER is used.

Definition at line 50 of file mlLogging.h.

Referenced by ml::TypedComputeClusters::process().

◆ mlErrorWithDump

#define mlErrorWithDump (   FUNCTION,
  ERRORCODE,
  OBJECT 
)    ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_ERROR, ERRORCODE, FUNCTION, (OBJECT), ML_NAMESPACE::internal::MLSecureGetRuntimeTypeId((OBJECT))).getStream()

Logs an error for FUNCTION with MLErrorCode ERRORCODE and additionally dumps the given OBJECT (which needs to support getTypeId()).

Definition at line 69 of file mlLogging.h.

◆ mlFatalError

#define mlFatalError (   FUNCTION,
  ... 
)    ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_FATAL, ML_NAMESPACE::internal::LogCollector::getErrorCode(__VA_ARGS__) ,FUNCTION).getStream()

Logs a fatal error for FUNCTION with optional MLErrorCode.

If MLErrorCode is omitted, ML_BAD_PARAMETER is used.

Definition at line 45 of file mlLogging.h.

◆ mlFatalErrorWithDump

#define mlFatalErrorWithDump (   FUNCTION,
  ERRORCODE,
  OBJECT 
)    ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_FATAL, ERRORCODE, FUNCTION, (OBJECT), ML_NAMESPACE::internal::MLSecureGetRuntimeTypeId((OBJECT))).getStream()

Logs a fatal error for FUNCTION with MLErrorCode ERRORCODE and additionally dumps the given OBJECT (which needs to support getTypeId()).

Definition at line 65 of file mlLogging.h.

◆ mlInfo

#define mlInfo (   FUNCTION)    ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_INFORMATION, ML_RESULT_OK, FUNCTION).getStream()

Logs an informational message.

Definition at line 60 of file mlLogging.h.

◆ mlInfoWithDump

#define mlInfoWithDump (   FUNCTION,
  OBJECT 
)    ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_INFORMATION, ML_RESULT_OK, FUNCTION, (OBJECT), ML_NAMESPACE::internal::MLSecureGetRuntimeTypeId((OBJECT))).getStream()

Logs an informational message for FUNCTION and additionally dumps the given OBJECT (which needs to support getTypeId()).

Definition at line 77 of file mlLogging.h.

◆ mlWarning

#define mlWarning (   FUNCTION,
  ... 
)    ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_WARNING, ML_NAMESPACE::internal::LogCollector::getErrorCode(__VA_ARGS__) , FUNCTION).getStream()

Logs a warning for FUNCTION with optional MLErrorCode.

If MLErrorCode is omitted, ML_BAD_PARAMETER is used.

Definition at line 55 of file mlLogging.h.

◆ mlWarningWithDump

#define mlWarningWithDump (   FUNCTION,
  ERRORCODE,
  OBJECT 
)    ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_WARNING, ERRORCODE, FUNCTION, (OBJECT), ML_NAMESPACE::internal::MLSecureGetRuntimeTypeId((OBJECT))).getStream()

Logs a warning for FUNCTION with MLErrorCode ERRORCODE and additionally dumps the given OBJECT (which needs to support getTypeId()).

Definition at line 73 of file mlLogging.h.