4#ifndef OPENVDB_UTIL_LOGGING_HAS_BEEN_INCLUDED
5#define OPENVDB_UTIL_LOGGING_HAS_BEEN_INCLUDED
7#include <openvdb/version.h>
62 using Ptr = std::shared_ptr<Sink>;
70 const std::string&
name()
const;
80 const char* file,
int line) = 0;
83 const std::string mName;
84 std::atomic<Level> mThreshold;
111 void append(
Level,
const std::string& message,
const char* file,
int line)
override;
114 std::atomic<bool> mUseColor;
138OPENVDB_API void dispatch(Level level,
const std::string& message,
139 const char* file,
int line);
150#define OPENVDB_LOG(level, message) \
152 if (openvdb::logging::isEnabledFor(openvdb::logging::Level::level)) { \
153 std::ostringstream _buf; \
155 openvdb::logging::internal::dispatch( \
156 openvdb::logging::Level::level, _buf.str(), __FILE__, __LINE__); \
161#define OPENVDB_LOG_INFO(message) OPENVDB_LOG(Info, message)
163#define OPENVDB_LOG_WARN(message) OPENVDB_LOG(Warn, message)
165#define OPENVDB_LOG_ERROR(message) OPENVDB_LOG(Error, message)
167#define OPENVDB_LOG_FATAL(message) OPENVDB_LOG(Fatal, message)
170#define OPENVDB_LOG_DEBUG(message)
173#define OPENVDB_LOG_DEBUG(message) OPENVDB_LOG(Debug, message)
177#define OPENVDB_LOG_DEBUG_RUNTIME(message) OPENVDB_LOG(Debug, message)
static bool stderrIsTerminal()
Return true if stderr is connected to a terminal.
ConsoleSink(bool useColor=stderrIsTerminal())
void append(Level, const std::string &message, const char *file, int line) override
static const char * defaultName()
The name under which this sink is registered.
const std::string & name() const
Sink(const std::string &name, Level threshold=Level::Debug)
virtual void append(Level level, const std::string &message, const char *file, int line)=0
std::shared_ptr< Sink > Ptr
Definition logging.h:62
Level
Message severity level, in increasing order of severity.
Definition logging.h:21
@ Info
Definition logging.h:21
@ Warn
Definition logging.h:21
@ Fatal
Definition logging.h:21
@ Error
Definition logging.h:21
@ Debug
Definition logging.h:21
Sink::Ptr findSink(const std::string &name)
Return the sink with the given name, or nullptr.
bool isEnabledFor(Level)
Return true if a message of the given level would be logged.
void addSink(const Sink::Ptr &)
Register a sink. Replaces any existing sink with the same name.
void setLevel(Level)
Set the severity threshold. Messages below this are dropped.
Level getLevel()
Return the current severity threshold. Messages below this are dropped.
bool removeSink(const std::string &name)
Remove the sink with the given name. Returns true if one was removed.
void initialize(bool useColor=ConsoleSink::stderrIsTerminal())
Install the default console sink if no sink has been installed yet.
Definition Exceptions.h:13
Level level
Definition logging.h:129
LevelScope(Level newLevel)
Definition logging.h:130
~LevelScope()
Definition logging.h:131
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:291