VTK  9.1.0
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. More...
 
#define vtkVLogF(level, ...)
 Add to log given the verbosity level. More...
 
#define vtkLogF(verbosity_name, ...)   vtkVLogF(vtkLogger::VERBOSITY_##verbosity_name, __VA_ARGS__)
 Add to log given the verbosity level. More...
 
#define vtkVLog(level, x)
 Add to log given the verbosity level. More...
 
#define vtkLog(verbosity_name, x)   vtkVLog(vtkLogger::VERBOSITY_##verbosity_name, x)
 Add to log given the verbosity level. More...
 
#define vtkVLogIfF(level, cond, ...)
 Add to log only when the cond passes. More...
 
#define vtkLogIfF(verbosity_name, cond, ...)    vtkVLogIfF(vtkLogger::VERBOSITY_##verbosity_name, cond, __VA_ARGS__)
 Add to log only when the cond passes. More...
 
#define vtkVLogIf(level, cond, x)
 Add to log only when the cond passes. More...
 
#define vtkLogIf(verbosity_name, cond, x)   vtkVLogIf(vtkLogger::VERBOSITY_##verbosity_name, cond, x)
 Add to log only when the cond passes. More...
 
#define vtkLogStartScope(verbosity_name, id)    vtkLogger::StartScope(vtkLogger::VERBOSITY_##verbosity_name, id, __FILE__, __LINE__)
 Explicitly mark start and end of log scope. More...
 
#define vtkLogEndScope(id)   vtkLogger::EndScope(id)
 Explicitly mark start and end of log scope. More...
 
#define vtkLogStartScopeF(verbosity_name, id, ...)    vtkLogger::StartScopeF(vtkLogger::VERBOSITY_##verbosity_name, id, __FILE__, __LINE__, __VA_ARGS__)
 Explicitly mark start and end of log scope. More...
 
#define vtkVLogStartScope(level, id)   vtkLogger::StartScope(level, id, __FILE__, __LINE__)
 Explicitly mark start and end of log scope. More...
 
#define vtkVLogStartScopeF(level, id, ...)    vtkLogger::StartScopeF(level, id, __FILE__, __LINE__, __VA_ARGS__)
 Explicitly mark start and end of log scope. More...
 

Macro Definition Documentation

◆ VTK_PRINTF_LIKE

#define VTK_PRINTF_LIKE (   fmtarg,
  firstvararg 
)

Definition at line 192 of file vtkLogger.h.

◆ VTK_FORMAT_STRING_TYPE

#define VTK_FORMAT_STRING_TYPE   const char*

Definition at line 193 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.
@ level
Definition: vtkX3D.h:401

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 480 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 484 of file vtkLogger.h.

◆ vtkVLog

#define vtkVLog (   level,
 
)
Value:
{ \
vtkOStrStreamWrapper::EndlType endl; \
vtkOStrStreamWrapper vtkmsg; \
vtkmsg << "" x; \
vtkLogger::Log(level, __FILE__, __LINE__, vtkmsg.str()); \
vtkmsg.rdbuf()->freeze(0); \
}
static void Log(Verbosity verbosity, VTK_FILEPATH const char *fname, unsigned int lineno, const char *txt)
static void UseEndl(const EndlType &)
Implementation detail to allow macros to provide an endl that may or may not be used.

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 485 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 495 of file vtkLogger.h.

◆ vtkVLogIfF

#define vtkVLogIfF (   level,
  cond,
  ... 
)
Value:
((level) > vtkLogger::GetCurrentVerbosityCutoff() || (cond) == false) \
? (void)0 \
: vtkLogger::LogF(level, __FILE__, __LINE__, __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 511 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 516 of file vtkLogger.h.

◆ vtkVLogIf

#define vtkVLogIf (   level,
  cond,
 
)
Value:
{ \
vtkOStrStreamWrapper::EndlType endl; \
vtkOStrStreamWrapper vtkmsg; \
vtkmsg << "" x; \
vtkLogger::Log(level, __FILE__, __LINE__, vtkmsg.str()); \
vtkmsg.rdbuf()->freeze(0); \
}

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 519 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 529 of file vtkLogger.h.

◆ VTKLOG_CONCAT_IMPL

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

Definition at line 532 of file vtkLogger.h.

◆ VTKLOG_CONCAT

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

Definition at line 533 of file vtkLogger.h.

◆ VTKLOG_ANONYMOUS_VARIABLE

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

Definition at line 534 of file vtkLogger.h.

◆ vtkVLogScopeF

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

Definition at line 536 of file vtkLogger.h.

◆ vtkLogScopeF

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

Definition at line 541 of file vtkLogger.h.

◆ vtkLogScopeFunction

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

Definition at line 544 of file vtkLogger.h.

◆ vtkVLogScopeFunction

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

Definition at line 545 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 552 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 554 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 556 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 559 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 560 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 569 of file vtkLogger.h.