VTK  9.4.20241108
Classes | Macros
vtkLogger.h File Reference
#include "vtkObjectBase.h"
#include "vtkSetGet.h"
#include <string>
Include dependency graph for vtkLogger.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  vtkLogger
 logging framework for use in VTK and in applications based on VTK More...
 
struct  vtkLogger::Message
 The message structure that is passed to custom callbacks registered using vtkLogger::AddCallback. More...
 
class  vtkLogger::LogScopeRAII
 

Macros

#define VTK_PRINTF_LIKE(fmtarg, firstvararg)
 
#define VTK_FORMAT_STRING_TYPE   const char*
 
#define VTKLOG_CONCAT_IMPL(s1, s2)   s1##s2
 
#define VTKLOG_CONCAT(s1, s2)   VTKLOG_CONCAT_IMPL(s1, s2)
 
#define VTKLOG_ANONYMOUS_VARIABLE(x)   VTKLOG_CONCAT(x, __LINE__)
 
#define vtkVLogScopeF(level, ...)
 
#define vtkLogScopeF(verbosity_name, ...)    vtkVLogScopeF(vtkLogger::VERBOSITY_##verbosity_name, __VA_ARGS__)
 
#define vtkLogScopeFunction(verbosity_name)   vtkLogScopeF(verbosity_name, "%s", __func__)
 
#define vtkVLogScopeFunction(level)   vtkVLogScopeF(level, "%s", __func__)
 
#define vtkLogIdentifier(vtkobject)   vtkLogger::GetIdentifier(vtkobject).c_str()
 Convenience macro to generate an identifier string for any vtkObjectBase subclass.
 
#define vtkVLogF(level, ...)
 Add to log given the verbosity level.
 
#define vtkLogF(verbosity_name, ...)   vtkVLogF(vtkLogger::VERBOSITY_##verbosity_name, __VA_ARGS__)
 Add to log given the verbosity level.
 
#define vtkVLog(level, x)
 Add to log given the verbosity level.
 
#define vtkLog(verbosity_name, x)   vtkVLog(vtkLogger::VERBOSITY_##verbosity_name, x)
 Add to log given the verbosity level.
 
#define vtkVLogIfF(level, cond, ...)
 Add to log only when the cond passes.
 
#define vtkLogIfF(verbosity_name, cond, ...)    vtkVLogIfF(vtkLogger::VERBOSITY_##verbosity_name, cond, __VA_ARGS__)
 Add to log only when the cond passes.
 
#define vtkVLogIf(level, cond, x)
 Add to log only when the cond passes.
 
#define vtkLogIf(verbosity_name, cond, x)   vtkVLogIf(vtkLogger::VERBOSITY_##verbosity_name, cond, x)
 Add to log only when the cond passes.
 
#define vtkLogStartScope(verbosity_name, id)    vtkLogger::StartScope(vtkLogger::VERBOSITY_##verbosity_name, id, __FILE__, __LINE__)
 Explicitly mark start and end of log scope.
 
#define vtkLogEndScope(id)   vtkLogger::EndScope(id)
 Explicitly mark start and end of log scope.
 
#define vtkLogStartScopeF(verbosity_name, id, ...)    vtkLogger::StartScopeF(vtkLogger::VERBOSITY_##verbosity_name, id, __FILE__, __LINE__, __VA_ARGS__)
 Explicitly mark start and end of log scope.
 
#define vtkVLogStartScope(level, id)   vtkLogger::StartScope(level, id, __FILE__, __LINE__)
 Explicitly mark start and end of log scope.
 
#define vtkVLogStartScopeF(level, id, ...)    vtkLogger::StartScopeF(level, id, __FILE__, __LINE__, __VA_ARGS__)
 Explicitly mark start and end of log scope.
 

Macro Definition Documentation

◆ VTK_PRINTF_LIKE

#define VTK_PRINTF_LIKE (   fmtarg,
  firstvararg 
)

Definition at line 200 of file vtkLogger.h.

◆ VTK_FORMAT_STRING_TYPE

#define VTK_FORMAT_STRING_TYPE   const char*

Definition at line 201 of file vtkLogger.h.

◆ vtkVLogF

#define vtkVLogF (   level,
  ... 
)
Value:
? (void)0 \
: vtkLogger::LogF(level, __FILE__, __LINE__, __VA_ARGS__)
static void LogF(Verbosity verbosity, VTK_FILEPATH const char *fname, unsigned int lineno, VTK_FORMAT_STRING_TYPE format,...) VTK_PRINTF_LIKE(4
static Verbosity GetCurrentVerbosityCutoff()
Returns the maximum verbosity of all log outputs.

Add to log given the verbosity level.

The text will be logged when the log verbosity is set to the specified level or higher.

// using printf-style
vtkLogF(INFO, "Hello %s", "world!");
vtkVLogF(vtkLogger::VERBOSITY_INFO, "Hello %s", "world!");

// using streams
vtkLog(INFO, "Hello " << "world!");
vtkVLog(vtkLogger::VERBOSITY_INFO, << "Hello world!");

Definition at line 495 of file vtkLogger.h.

◆ vtkLogF

#define vtkLogF (   verbosity_name,
  ... 
)    vtkVLogF(vtkLogger::VERBOSITY_##verbosity_name, __VA_ARGS__)

Add to log given the verbosity level.

The text will be logged when the log verbosity is set to the specified level or higher.

// using printf-style
vtkLogF(INFO, "Hello %s", "world!");
vtkVLogF(vtkLogger::VERBOSITY_INFO, "Hello %s", "world!");

// using streams
vtkLog(INFO, "Hello " << "world!");
vtkVLog(vtkLogger::VERBOSITY_INFO, << "Hello world!");

Definition at line 499 of file vtkLogger.h.

◆ vtkVLog

#define vtkVLog (   level,
 
)
Value:
do \
{ \
{ \
vtkOStrStreamWrapper::UseEndl(endl); \
vtkmsg << "" x; \
vtkLogger::Log(level, __FILE__, __LINE__, vtkmsg.str()); \
vtkmsg.rdbuf()->freeze(0); \
} \
} while (false)
Wrapper for ostrstream.
char * str()
Get the string that has been written.
void freeze()
Set whether the memory is frozen.
vtkOStrStreamWrapper * rdbuf()
Returns a pointer to this class.

Add to log given the verbosity level.

The text will be logged when the log verbosity is set to the specified level or higher.

// using printf-style
vtkLogF(INFO, "Hello %s", "world!");
vtkVLogF(vtkLogger::VERBOSITY_INFO, "Hello %s", "world!");

// using streams
vtkLog(INFO, "Hello " << "world!");
vtkVLog(vtkLogger::VERBOSITY_INFO, << "Hello world!");

Definition at line 500 of file vtkLogger.h.

◆ vtkLog

#define vtkLog (   verbosity_name,
 
)    vtkVLog(vtkLogger::VERBOSITY_##verbosity_name, x)

Add to log given the verbosity level.

The text will be logged when the log verbosity is set to the specified level or higher.

// using printf-style
vtkLogF(INFO, "Hello %s", "world!");
vtkVLogF(vtkLogger::VERBOSITY_INFO, "Hello %s", "world!");

// using streams
vtkLog(INFO, "Hello " << "world!");
vtkVLog(vtkLogger::VERBOSITY_INFO, << "Hello world!");

Definition at line 513 of file vtkLogger.h.

◆ vtkVLogIfF

#define vtkVLogIfF (   level,
  cond,
  ... 
)
Value:
((level) > vtkLogger::GetCurrentVerbosityCutoff() || (cond) == false) \
? (void)0 \
: vtkLogger::LogF(level, __FILE__, __LINE__, __VA_ARGS__)
logging framework for use in VTK and in applications based on VTK
Definition vtkLogger.h:206

Add to log only when the cond passes.

// using printf-style
vtkLogIfF(ERROR, ptr == nullptr, "`ptr` cannot be null!");
vtkVLogIfF(vtkLogger::VERBOSITY_ERROR, ptr == nullptr, "`ptr` cannot be null!");

// using streams
vtkLogIf(ERROR, ptr == nullptr, "`ptr` cannot be null!");
vtkVLogIf(vtkLogger::VERBOSITY_ERROR, ptr == nullptr, << "`ptr` cannot be null!");

Definition at line 529 of file vtkLogger.h.

◆ vtkLogIfF

#define vtkLogIfF (   verbosity_name,
  cond,
  ... 
)     vtkVLogIfF(vtkLogger::VERBOSITY_##verbosity_name, cond, __VA_ARGS__)

Add to log only when the cond passes.

// using printf-style
vtkLogIfF(ERROR, ptr == nullptr, "`ptr` cannot be null!");
vtkVLogIfF(vtkLogger::VERBOSITY_ERROR, ptr == nullptr, "`ptr` cannot be null!");

// using streams
vtkLogIf(ERROR, ptr == nullptr, "`ptr` cannot be null!");
vtkVLogIf(vtkLogger::VERBOSITY_ERROR, ptr == nullptr, << "`ptr` cannot be null!");

Definition at line 534 of file vtkLogger.h.

◆ vtkVLogIf

#define vtkVLogIf (   level,
  cond,
 
)
Value:
do \
{ \
if ((level) <= vtkLogger::GetCurrentVerbosityCutoff() && (cond)) \
{ \
vtkOStrStreamWrapper::UseEndl(endl); \
vtkmsg << "" x; \
vtkLogger::Log(level, __FILE__, __LINE__, vtkmsg.str()); \
vtkmsg.rdbuf()->freeze(0); \
} \
} while (false)

Add to log only when the cond passes.

// using printf-style
vtkLogIfF(ERROR, ptr == nullptr, "`ptr` cannot be null!");
vtkVLogIfF(vtkLogger::VERBOSITY_ERROR, ptr == nullptr, "`ptr` cannot be null!");

// using streams
vtkLogIf(ERROR, ptr == nullptr, "`ptr` cannot be null!");
vtkVLogIf(vtkLogger::VERBOSITY_ERROR, ptr == nullptr, << "`ptr` cannot be null!");

Definition at line 537 of file vtkLogger.h.

◆ vtkLogIf

#define vtkLogIf (   verbosity_name,
  cond,
 
)    vtkVLogIf(vtkLogger::VERBOSITY_##verbosity_name, cond, x)

Add to log only when the cond passes.

// using printf-style
vtkLogIfF(ERROR, ptr == nullptr, "`ptr` cannot be null!");
vtkVLogIfF(vtkLogger::VERBOSITY_ERROR, ptr == nullptr, "`ptr` cannot be null!");

// using streams
vtkLogIf(ERROR, ptr == nullptr, "`ptr` cannot be null!");
vtkVLogIf(vtkLogger::VERBOSITY_ERROR, ptr == nullptr, << "`ptr` cannot be null!");

Definition at line 550 of file vtkLogger.h.

◆ VTKLOG_CONCAT_IMPL

#define VTKLOG_CONCAT_IMPL (   s1,
  s2 
)    s1##s2

Definition at line 553 of file vtkLogger.h.

◆ VTKLOG_CONCAT

#define VTKLOG_CONCAT (   s1,
  s2 
)    VTKLOG_CONCAT_IMPL(s1, s2)

Definition at line 554 of file vtkLogger.h.

◆ VTKLOG_ANONYMOUS_VARIABLE

#define VTKLOG_ANONYMOUS_VARIABLE (   x)    VTKLOG_CONCAT(x, __LINE__)

Definition at line 555 of file vtkLogger.h.

◆ vtkVLogScopeF

#define vtkVLogScopeF (   level,
  ... 
)
Value:
: vtkLogger::LogScopeRAII(level, __FILE__, __LINE__, __VA_ARGS__)
#define VTKLOG_ANONYMOUS_VARIABLE(x)
Definition vtkLogger.h:555

Definition at line 557 of file vtkLogger.h.

◆ vtkLogScopeF

#define vtkLogScopeF (   verbosity_name,
  ... 
)     vtkVLogScopeF(vtkLogger::VERBOSITY_##verbosity_name, __VA_ARGS__)

Definition at line 562 of file vtkLogger.h.

◆ vtkLogScopeFunction

#define vtkLogScopeFunction (   verbosity_name)    vtkLogScopeF(verbosity_name, "%s", __func__)

Definition at line 565 of file vtkLogger.h.

◆ vtkVLogScopeFunction

#define vtkVLogScopeFunction (   level)    vtkVLogScopeF(level, "%s", __func__)

Definition at line 566 of file vtkLogger.h.

◆ vtkLogStartScope

#define vtkLogStartScope (   verbosity_name,
  id 
)     vtkLogger::StartScope(vtkLogger::VERBOSITY_##verbosity_name, id, __FILE__, __LINE__)

Explicitly mark start and end of log scope.

This is useful in cases where the start and end of the scope does not happen within the same C++ scope.

Definition at line 573 of file vtkLogger.h.

◆ vtkLogEndScope

#define vtkLogEndScope (   id)    vtkLogger::EndScope(id)

Explicitly mark start and end of log scope.

This is useful in cases where the start and end of the scope does not happen within the same C++ scope.

Definition at line 575 of file vtkLogger.h.

◆ vtkLogStartScopeF

#define vtkLogStartScopeF (   verbosity_name,
  id,
  ... 
)     vtkLogger::StartScopeF(vtkLogger::VERBOSITY_##verbosity_name, id, __FILE__, __LINE__, __VA_ARGS__)

Explicitly mark start and end of log scope.

This is useful in cases where the start and end of the scope does not happen within the same C++ scope.

Definition at line 577 of file vtkLogger.h.

◆ vtkVLogStartScope

#define vtkVLogStartScope (   level,
  id 
)    vtkLogger::StartScope(level, id, __FILE__, __LINE__)

Explicitly mark start and end of log scope.

This is useful in cases where the start and end of the scope does not happen within the same C++ scope.

Definition at line 580 of file vtkLogger.h.

◆ vtkVLogStartScopeF

#define vtkVLogStartScopeF (   level,
  id,
  ... 
)     vtkLogger::StartScopeF(level, id, __FILE__, __LINE__, __VA_ARGS__)

Explicitly mark start and end of log scope.

This is useful in cases where the start and end of the scope does not happen within the same C++ scope.

Definition at line 581 of file vtkLogger.h.

◆ vtkLogIdentifier

#define vtkLogIdentifier (   vtkobject)    vtkLogger::GetIdentifier(vtkobject).c_str()

Convenience macro to generate an identifier string for any vtkObjectBase subclass.

Note
do not store the returned value as it returns a char* pointer to a temporary std::string that will be released as soon as it goes out of scope.

Definition at line 590 of file vtkLogger.h.