VTK  9.4.20251007
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)
#define VTKLOG_CONCAT(s1, s2)
#define VTKLOG_ANONYMOUS_VARIABLE(x)
#define vtkVLogScopeF(level, ...)
#define vtkLogScopeF(verbosity_name, ...)
#define vtkLogScopeFunction(verbosity_name)
#define vtkVLogScopeFunction(level)
#define vtkLogIdentifier(vtkobject)
 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, ...)
 Add to log given the verbosity level.
#define vtkVLog(level, x)
 Add to log given the verbosity level.
#define vtkLog(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, ...)
 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)
 Add to log only when the cond passes.
#define vtkLogStartScope(verbosity_name, id)
 Explicitly mark start and end of log scope.
#define vtkLogEndScope(id)
 Explicitly mark start and end of log scope.
#define vtkLogStartScopeF(verbosity_name, id, ...)
 Explicitly mark start and end of log scope.
#define vtkVLogStartScope(level, id)
 Explicitly mark start and end of log scope.
#define vtkVLogStartScopeF(level, id, ...)
 Explicitly mark start and end of log scope.

Macro Definition Documentation

◆ VTK_PRINTF_LIKE

#define VTK_PRINTF_LIKE ( fmtarg,
firstvararg )

Definition at line 181 of file vtkLogger.h.

◆ VTK_FORMAT_STRING_TYPE

#define VTK_FORMAT_STRING_TYPE   const char*

Definition at line 182 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 476 of file vtkLogger.h.

◆ vtkLogF

#define vtkLogF ( verbosity_name,
... )
Value:
vtkVLogF(vtkLogger::VERBOSITY_##verbosity_name, __VA_ARGS__)
#define vtkVLogF(level,...)
Add to log given the verbosity level.
Definition vtkLogger.h:476

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.

◆ vtkVLog

#define vtkVLog ( level,
x )
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 481 of file vtkLogger.h.

◆ vtkLog

#define vtkLog ( verbosity_name,
x )
Value:
vtkVLog(vtkLogger::VERBOSITY_##verbosity_name, x)
#define vtkVLog(level, x)
Add to log given the verbosity level.
Definition vtkLogger.h:481

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 494 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:187

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

◆ vtkLogIfF

#define vtkLogIfF ( verbosity_name,
cond,
... )
Value:
vtkVLogIfF(vtkLogger::VERBOSITY_##verbosity_name, cond, __VA_ARGS__)
#define vtkVLogIfF(level, cond,...)
Add to log only when the cond passes.
Definition vtkLogger.h:510

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

◆ vtkVLogIf

#define vtkVLogIf ( level,
cond,
x )
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 518 of file vtkLogger.h.

◆ vtkLogIf

#define vtkLogIf ( verbosity_name,
cond,
x )
Value:
vtkVLogIf(vtkLogger::VERBOSITY_##verbosity_name, cond, x)
#define vtkVLogIf(level, cond, x)
Add to log only when the cond passes.
Definition vtkLogger.h:518

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

◆ VTKLOG_CONCAT_IMPL

#define VTKLOG_CONCAT_IMPL ( s1,
s2 )
Value:
s1##s2
RealT s2
Definition PyrC2Basis.h:21

Definition at line 534 of file vtkLogger.h.

◆ VTKLOG_CONCAT

#define VTKLOG_CONCAT ( s1,
s2 )
Value:
#define VTKLOG_CONCAT_IMPL(s1, s2)
Definition vtkLogger.h:534

Definition at line 535 of file vtkLogger.h.

◆ VTKLOG_ANONYMOUS_VARIABLE

#define VTKLOG_ANONYMOUS_VARIABLE ( x)
Value:
VTKLOG_CONCAT(x, __LINE__)
#define VTKLOG_CONCAT(s1, s2)
Definition vtkLogger.h:535

Definition at line 536 of file vtkLogger.h.

◆ vtkVLogScopeF

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

Definition at line 538 of file vtkLogger.h.

◆ vtkLogScopeF

#define vtkLogScopeF ( verbosity_name,
... )
Value:
vtkVLogScopeF(vtkLogger::VERBOSITY_##verbosity_name, __VA_ARGS__)
#define vtkVLogScopeF(level,...)
Definition vtkLogger.h:538

Definition at line 543 of file vtkLogger.h.

◆ vtkLogScopeFunction

#define vtkLogScopeFunction ( verbosity_name)
Value:
vtkLogScopeF(verbosity_name, "%s", __func__)
#define vtkLogScopeF(verbosity_name,...)
Definition vtkLogger.h:543

Definition at line 546 of file vtkLogger.h.

◆ vtkVLogScopeFunction

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

Definition at line 547 of file vtkLogger.h.

◆ vtkLogStartScope

#define vtkLogStartScope ( verbosity_name,
id )
Value:
vtkLogger::StartScope(vtkLogger::VERBOSITY_##verbosity_name, id, __FILE__, __LINE__)
static void StartScope(Verbosity verbosity, const char *id, VTK_FILEPATH const char *fname, unsigned int lineno)

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.

◆ vtkLogEndScope

#define vtkLogEndScope ( id)
Value:
static void EndScope(const char *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 556 of file vtkLogger.h.

◆ vtkLogStartScopeF

#define vtkLogStartScopeF ( verbosity_name,
id,
... )
Value:
vtkLogger::StartScopeF(vtkLogger::VERBOSITY_##verbosity_name, id, __FILE__, __LINE__, __VA_ARGS__)
static void static void StartScopeF(Verbosity verbosity, const char *id, VTK_FILEPATH const char *fname, unsigned int lineno, VTK_FORMAT_STRING_TYPE format,...) VTK_PRINTF_LIKE(5

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

◆ vtkVLogStartScope

#define vtkVLogStartScope ( level,
id )
Value:
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 561 of file vtkLogger.h.

◆ vtkVLogStartScopeF

#define vtkVLogStartScopeF ( level,
id,
... )
Value:
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 562 of file vtkLogger.h.

◆ vtkLogIdentifier

#define vtkLogIdentifier ( vtkobject)
Value:
vtkLogger::GetIdentifier(vtkobject).c_str()
static std::string GetIdentifier(vtkObjectBase *obj)
Returns a printable string for a vtkObjectBase instance.

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