20 #if !defined(__MITSUBA_CORE_LOGGER_H_)
21 #define __MITSUBA_CORE_LOGGER_H_
35 #define Log(level, fmt, ...) do { \
36 mitsuba::Thread *thread = mitsuba::Thread::getThread(); \
37 if (EXPECT_NOT_TAKEN(thread == NULL)) \
38 throw std::runtime_error("Null thread pointer"); \
39 mitsuba::Logger *logger = thread->getLogger(); \
40 if (logger != NULL && level >= logger->getLogLevel()) \
41 logger->log(level, m_theClass, \
42 __FILE__, __LINE__, fmt, ## __VA_ARGS__); \
49 #define SLog(level, fmt, ...) do { \
50 mitsuba::Thread *thread = mitsuba::Thread::getThread(); \
51 if (EXPECT_NOT_TAKEN(thread == NULL)) \
52 throw std::runtime_error("Null thread pointer"); \
53 mitsuba::Logger *logger = thread->getLogger(); \
54 if (logger != NULL && level >= logger->getLogLevel()) \
55 logger->log(level, NULL, \
56 __FILE__, __LINE__, fmt, ## __VA_ARGS__); \
62 #define Assert(cond) ((void) 0)
63 #define AssertEx(cond, explanation) ((void) 0)
64 #define SAssert(cond) ((void) 0)
65 #define SAssertEx(cond, explanation) ((void) 0)
73 #define Assert(cond) do { \
74 if (!(cond)) Log(EError, "Assertion \"%s\" failed in %s:%i", \
75 #cond, __FILE__, __LINE__); \
79 #define SAssert(cond) do { \
80 if (!(cond)) SLog(EError, "Assertion \"%s\" failed in %s:%i", \
81 #cond, __FILE__, __LINE__); \
85 #define AssertEx(cond, explanation) do { \
86 if (!(cond)) Log(EError, "Assertion \"%s\" failed in %s:%i (" explanation ")", \
87 #cond, __FILE__, __LINE__); \
91 #define SAssertEx(cond, explanation) do { \
92 if (!(cond)) SLog(EError, "Assertion \"%s\" failed in %s:%i (" explanation ")", \
93 #cond, __FILE__, __LINE__); \
98 #define NotImplementedError(funcName) \
99 throw std::runtime_error(formatString("%s::" funcName "(): Not implemented!", \
100 getClass()->getName().c_str()));
133 const char *fileName,
int lineNumber,
134 const char *fmt, ...);
147 void logProgress(
Float progress,
const std::string &name,
148 const std::string &formatted,
const std::string &eta,
172 void addAppender(
Appender *appender);
175 void removeAppender(
Appender *appender);
178 void clearAppenders();
200 bool readLog(std::string &target);
220 std::vector<
Appender *> m_appenders;
221 size_t m_warningCount;
Formatter * getFormatter()
Return the logger's formatter implementation.
Definition: logger.h:193
const Appender * getAppender(size_t index) const
Return one of the appenders.
Definition: logger.h:187
Collects various rendering statistics and presents them in a human-readable form. ...
Definition: statistics.h:339
static void staticInitialization()
Initializes the built-in reference count debugger (if enabled)
ELogLevel getErrorLevel() const
Return the current error level.
Definition: logger.h:169
#define MTS_EXPORT_CORE
Definition: getopt.h:29
Debug message, usually turned off.
Definition: formatter.h:30
Appender * getAppender(size_t index)
Return one of the appenders.
Definition: logger.h:184
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
Reference counting helper.
Definition: ref.h:40
Stores meta-information about Object instances.
Definition: class.h:43
This class defines an abstract destination for logging-relevant information.
Definition: appender.h:33
ELogLevel
Available Log message types.
Definition: formatter.h:28
Responsible for processing log messages.
Definition: logger.h:116
Parent of all Mitsuba classes.
Definition: object.h:38
static void staticShutdown()
Free the memory taken by staticInitialization()
size_t getWarningCount() const
Return the number of warnings reported so far.
Definition: logger.h:203
Thin wrapper around the recursive boost thread lock.
Definition: lock.h:34
ELogLevel getLogLevel() const
Return the current log level.
Definition: logger.h:166
size_t getAppenderCount() const
Return the number of registered appenders.
Definition: logger.h:181