OpenVDB 14.0.0
Loading...
Searching...
No Matches
logging.h File Reference
#include <openvdb/version.h>
#include <openvdb/Platform.h>
#include <atomic>
#include <memory>
#include <sstream>
#include <string>

Go to the source code of this file.

Classes

class  Sink
 Receives formatted log messages. Subclass this to route OpenVDB diagnostics into a host application. More...
class  ConsoleSink
 The sink installed by default, writing to std::cerr. More...
struct  LevelScope
 Sets the level on construction and restores the previous level on destruction. More...

Namespaces

namespace  openvdb
namespace  openvdb::v14_0
namespace  openvdb::v14_0::logging

Macros

#define OPENVDB_LOG(level, message)
#define OPENVDB_LOG_INFO(message)
 Log an info message of the form 'someVar << "some text" << ...'.
#define OPENVDB_LOG_WARN(message)
 Log a warning message of the form 'someVar << "some text" << ...'.
#define OPENVDB_LOG_ERROR(message)
 Log an error message of the form 'someVar << "some text" << ...'.
#define OPENVDB_LOG_FATAL(message)
 Log a fatal error message of the form 'someVar << "some text" << ...'.
#define OPENVDB_LOG_DEBUG(message)
 In debug builds only, log a debugging message of the form 'someVar << "text" << ...'.
#define OPENVDB_LOG_DEBUG_RUNTIME(message)
 Log a debugging message in both debug and optimized builds.

Enumerations

enum class  Level {
  Debug = 0 , Info , Warn , Error ,
  Fatal
}
 Message severity level, in increasing order of severity. More...

Functions

Level getLevel ()
 Return the current severity threshold. Messages below this are dropped.
void setLevel (Level)
 Set the severity threshold. Messages below this are dropped.
bool isEnabledFor (Level)
 Return true if a message of the given level would be logged.
void setLevel (int &argc, char *argv[])
 If "-debug", "-info", "-warn", "-error" or "-fatal" is found in the given array of command-line arguments, set the logging level appropriately and remove the relevant argument(s) from the array.
void addSink (const Sink::Ptr &)
 Register a sink. Replaces any existing sink with the same name.
bool removeSink (const std::string &name)
 Remove the sink with the given name. Returns true if one was removed.
Sink::Ptr findSink (const std::string &name)
 Return the sink with the given name, or nullptr.
void initialize (bool useColor=ConsoleSink::stderrIsTerminal())
 Install the default console sink if no sink has been installed yet.
void initialize (int &argc, char *argv[], bool useColor=ConsoleSink::stderrIsTerminal())
 Initialize and then apply any level flags found in the arguments.

Macro Definition Documentation

◆ OPENVDB_LOG

#define OPENVDB_LOG ( level,
message )
Value:
do { \
if (openvdb::logging::isEnabledFor(openvdb::logging::Level::level)) { \
std::ostringstream _buf; \
_buf << message; \
openvdb::logging::internal::dispatch( \
openvdb::logging::Level::level, _buf.str(), __FILE__, __LINE__); \
} \
} while (0)

◆ OPENVDB_LOG_DEBUG

#define OPENVDB_LOG_DEBUG ( message)
Value:
OPENVDB_LOG(Debug, message)
#define OPENVDB_LOG(level, message)
Definition logging.h:150

In debug builds only, log a debugging message of the form 'someVar << "text" << ...'.

◆ OPENVDB_LOG_DEBUG_RUNTIME

#define OPENVDB_LOG_DEBUG_RUNTIME ( message)
Value:
OPENVDB_LOG(Debug, message)

Log a debugging message in both debug and optimized builds.

Warning
Don't use this in performance-critical code.

◆ OPENVDB_LOG_ERROR

#define OPENVDB_LOG_ERROR ( message)
Value:
OPENVDB_LOG(Error, message)

Log an error message of the form 'someVar << "some text" << ...'.

◆ OPENVDB_LOG_FATAL

#define OPENVDB_LOG_FATAL ( message)
Value:
OPENVDB_LOG(Fatal, message)

Log a fatal error message of the form 'someVar << "some text" << ...'.

◆ OPENVDB_LOG_INFO

#define OPENVDB_LOG_INFO ( message)
Value:
OPENVDB_LOG(Info, message)

Log an info message of the form 'someVar << "some text" << ...'.

◆ OPENVDB_LOG_WARN

#define OPENVDB_LOG_WARN ( message)
Value:
OPENVDB_LOG(Warn, message)

Log a warning message of the form 'someVar << "some text" << ...'.