diff --git a/include/mitsuba/core/logger.h b/include/mitsuba/core/logger.h index 0a2ad6b1..8e7c1f15 100644 --- a/include/mitsuba/core/logger.h +++ b/include/mitsuba/core/logger.h @@ -33,7 +33,10 @@ MTS_NAMESPACE_BEGIN /// Write a Log message to the console (to be used within subclasses of Object) #define Log(level, fmt, ...) do { \ - mitsuba::Logger *logger = mitsuba::Thread::getThread()->getLogger(); \ + mitsuba::Thread *thread = mitsuba::Thread::getThread(); \ + if (EXPECT_NOT_TAKEN(thread == NULL)) \ + throw std::runtime_error("Null thread pointer"); \ + mitsuba::Logger *logger = thread->getLogger(); \ if (level >= logger->getLogLevel()) \ logger->log(level, m_theClass, \ __FILE__, __LINE__, fmt, ## __VA_ARGS__); \ @@ -44,7 +47,10 @@ MTS_NAMESPACE_BEGIN * outside of classes that derive from Object) */ #define SLog(level, fmt, ...) do { \ - mitsuba::Logger *logger = mitsuba::Thread::getThread()->getLogger(); \ + mitsuba::Thread *thread = mitsuba::Thread::getThread(); \ + if (EXPECT_NOT_TAKEN(thread == NULL)) \ + throw std::runtime_error("Null thread pointer"); \ + mitsuba::Logger *logger = thread->getLogger(); \ if (level >= logger->getLogLevel()) \ logger->log(level, NULL, \ __FILE__, __LINE__, fmt, ## __VA_ARGS__); \