MeVisLab Toolbox Reference
Logging Macros

Macros to print debug information.

Defines all ML debug, tracing, and error handling macros.

Debug printing is controllable in and by the ML, and there are some constructs for selective debug printing. The required files are automatically included if using the standard ML include file mlModuleIncludes.h. The ML controls debug printing by the instance MLErrorOutput of the class ErrorOutput (from Project mlUtils). There, the configuration of debug outputs and the error handling system takes place. However, you should not use this instance or class directly. Better use the CoreControl module, which makes the important settings available (if that is possible by an, e.g., application like MeVisLab). There, debug printing can be enabled/disabled for the entire ML and debugging can be enabled/disabled for certain classes by the use of environment variables/debug symbols.

The following macros are currently available to be inserted in program code:

Normally, each debug output is related to a debug symbol, which must be enabled in the ML before the debug information can be printed.

Such a debug symbol can be defined as:

  • an environment variable before the ML or the application is started,
  • as a debug symbol in the CoreControl module when used in an application like MeVisLab, or
  • directly via programming in the global MLErrorOutput instance of the ML.

The third way, however, should only be used in modules dedicated for debug control or diagnostics and not in normal code.

All debug macros are not compiled in release mode to improve performance and to reduce the amount of code generated.

If debugging is enabled and the related debug symbol (or environment variable) for the macro is defined, then any of the debug macros will sent the

  • file name,
  • time stamp,
  • line number,
  • the debug symbo, and
  • the passed macro parameter COUTS

to the global instance MLErrorOutput of the ML. That instance then will sent this information to all registered instances, e.g., the modules MLConsole, MLLogFile, and application consoles in MeVisLab.

#define mlDebugConst(ENV_VAR, COUTS)
#define mlDebug(COUTS)
#define mlDebugConditional(COND_SYM, COUTS)
#define mlDebugPrint(COUTS)
#define mlDebugClass(CLASS_NAME, COUTS)

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

#define ML_PRINT_FATAL_ERROR(FUNC_NAME, REASON, HANDLING)
#define ML_PRINT_ERROR(FUNC_NAME, REASON, HANDLING)
#define ML_PRINT_WARNING(FUNC_NAME, REASON, HANDLING)
#define ML_PRINT_INFORMATION(FUNC_NAME, REASON, HANDLING)
#define ML_PRINT_INFO(FUNC_NAME, HANDLING)

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 that 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 ML_BAD_PARAMETER
Definition mlTypeDefs.h:822
#define mlError(FUNCTION,...)
Definition mlLogging.h:52
#define mlFatalError(FUNCTION, ...)
#define mlError(FUNCTION, ...)
#define mlWarning(FUNCTION, ...)
#define mlInfo(FUNCTION)
#define mlFatalErrorWithDump(FUNCTION, ERRORCODE, OBJECT)
 Logs a fatal error for FUNCTION with MLErrorCode ERRORCODE and additionally dumps the given OBJECT (which needs to support getTypeId()).
#define mlErrorWithDump(FUNCTION, ERRORCODE, OBJECT)
 Logs an error for FUNCTION with MLErrorCode ERRORCODE and additionally dumps the given OBJECT (which needs to support getTypeId()).
#define mlWarningWithDump(FUNCTION, ERRORCODE, OBJECT)
 Logs a warning for FUNCTION with MLErrorCode ERRORCODE and additionally dumps the given OBJECT (which needs to support getTypeId()).
#define mlInfoWithDump(FUNCTION, OBJECT)
 Logs an informational message for FUNCTION and additionally dumps the given OBJECT (which needs to support getTypeId()).

Detailed Description

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

Macro Definition Documentation

◆ ML_PRINT_ERROR

◆ ML_PRINT_FATAL_ERROR

◆ ML_PRINT_INFO

#define ML_PRINT_INFO ( FUNC_NAME,
HANDLING )
Value:
_ML_PRINT_INFORMATION_DUMP(FUNC_NAME, ML_RESULT_OK, HANDLING, nullptr, nullptr)
#define ML_RESULT_OK
No error. Everything seems to be okay.
Definition mlTypeDefs.h:723
#define _ML_PRINT_INFORMATION_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, RTYPE)

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 372 of file mlErrorMacros.h.

◆ ML_PRINT_INFORMATION

#define ML_PRINT_INFORMATION ( FUNC_NAME,
REASON,
HANDLING )
Value:
_ML_PRINT_INFORMATION_DUMP(FUNC_NAME, REASON, HANDLING, nullptr, nullptr)

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 364 of file mlErrorMacros.h.

◆ ML_PRINT_WARNING

#define ML_PRINT_WARNING ( FUNC_NAME,
REASON,
HANDLING )
Value:
_ML_PRINT_WARNING_DUMP(FUNC_NAME, REASON, HANDLING, nullptr, nullptr)
#define _ML_PRINT_WARNING_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, RTYPE)

Like ML_PRINT_WARNING_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped. Have a look at mlWarning for new style logging.

Definition at line 355 of file mlErrorMacros.h.

Referenced by ml::RasterFunction::_fillRaster(), ml::ITKMatrixFromMLMatrix(), ml::ITKPointSetFromBasePointer(), ml::ITKPolylineFromBasePointer(), ml::MLMatrixFromITKMatrix(), ml::MLVectorFromITKIndex(), and ml::MLVectorFromITKSize().

◆ mlDebug

#define mlDebug ( COUTS)

This macro prints debug information given by COUTS. It requires that the class has the runtime type system implemented. This way, 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 130 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. This way, it accesses the type ID and creates a 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 204 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.

For example, if the following macro is used in the class "MyModule":

mlDebugConditional("CASES", "Message1");
#define mlDebugConditional(COND_SYM, COUTS)
Definition mlDebug.h:172

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. This way, it accesses the type ID and creates a 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 172 of file mlDebug.h.

◆ mlDebugConst

#define mlDebugConst ( ENV_VAR,
COUTS )
Value:
_mlDebugConst(ENV_VAR, COUTS)
#define _mlDebugConst(ENV_VAR, COUTS)
Definition mlDebug.h:102

Public macro to be used instead of print debug information. See header documentation of this file for full documentation.

Definition at line 110 of file mlDebug.h.

◆ mlDebugPrint

#define mlDebugPrint ( COUTS)
Value:
#define ML_DEBUG_ENV_NAME
Define name of environment variable to control debug output for this module.

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 that 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 184 of file mlDebug.h.

◆ mlError

#define mlError ( FUNCTION,
... )
Value:
ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_ERROR, ML_NAMESPACE::internal::LogCollector::getErrorCode(__VA_ARGS__) , FUNCTION).getStream()
@ ML_ERROR
Definition mlTypeDefs.h:696

Logs an error for FUNCTION with optional MLErrorCode. If MLErrorCode is omitted, ML_BAD_PARAMETER is used.

Definition at line 52 of file mlLogging.h.

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

◆ mlErrorWithDump

#define mlErrorWithDump ( FUNCTION,
ERRORCODE,
OBJECT )
Value:
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 71 of file mlLogging.h.

◆ mlFatalError

#define mlFatalError ( FUNCTION,
... )
Value:
ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_FATAL, ML_NAMESPACE::internal::LogCollector::getErrorCode(__VA_ARGS__) ,FUNCTION).getStream()
@ ML_FATAL
Definition mlTypeDefs.h:697

Logs a fatal error for FUNCTION with optional MLErrorCode. If MLErrorCode is omitted, ML_BAD_PARAMETER is used.

Definition at line 47 of file mlLogging.h.

◆ mlFatalErrorWithDump

#define mlFatalErrorWithDump ( FUNCTION,
ERRORCODE,
OBJECT )
Value:
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 67 of file mlLogging.h.

◆ mlInfo

#define mlInfo ( FUNCTION)
Value:
ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_INFORMATION, ML_RESULT_OK, FUNCTION).getStream()
@ ML_INFORMATION
Definition mlTypeDefs.h:701

Logs an informational message.

Definition at line 62 of file mlLogging.h.

◆ mlInfoWithDump

#define mlInfoWithDump ( FUNCTION,
OBJECT )
Value:
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 79 of file mlLogging.h.

◆ mlWarning

#define mlWarning ( FUNCTION,
... )
Value:
ML_NAMESPACE::internal::LogCollector(__FILE__, __LINE__, ML_WARNING, ML_NAMESPACE::internal::LogCollector::getErrorCode(__VA_ARGS__) , FUNCTION).getStream()
@ ML_WARNING
Definition mlTypeDefs.h:695

Logs a warning for FUNCTION with optional MLErrorCode. If MLErrorCode is omitted, ML_BAD_PARAMETER is used.

Definition at line 57 of file mlLogging.h.

◆ mlWarningWithDump

#define mlWarningWithDump ( FUNCTION,
ERRORCODE,
OBJECT )
Value:
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 75 of file mlLogging.h.