diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Config.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/Config.h index e97e27af..08d4bbbb 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/Config.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Config.h @@ -24,6 +24,13 @@ freely, subject to the following restrictions: #ifndef __PolyVox_Config_H__ #define __PolyVox_Config_H__ +#define POLYVOX_LOG_TRACE_ENABLED +#define POLYVOX_LOG_DEBUG_ENABLED +#define POLYVOX_LOG_INFO_ENABLED +#define POLYVOX_LOG_WARNING_ENABLED +#define POLYVOX_LOG_ERROR_ENABLED +#define POLYVOX_LOG_FATAL_ENABLED + #define POLYVOX_ASSERTS_ENABLED #define POLYVOX_THROW_ENABLED diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Logging.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/Logging.h index 301bfa6a..0269b018 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/Logging.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Logging.h @@ -148,4 +148,322 @@ namespace PolyVox }; } +#ifdef POLYVOX_LOG_TRACE_ENABLED + + #define POLYVOX_LOG_TRACE(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getTraceStreamInstance()) << (message) << std::endl; \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_TRACE_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + if ((condition)) \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getTraceStreamInstance()) << (message) << std::endl; \ + } \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + +#else + + #define POLYVOX_LOG_TRACE(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_TRACE_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(condition); POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + +#endif + +#ifdef POLYVOX_LOG_DEBUG_ENABLED + + #define POLYVOX_LOG_DEBUG(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getDebugStreamInstance()) << (message) << std::endl; \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_DEBUG_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + if ((condition)) \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getDebugStreamInstance()) << (message) << std::endl; \ + } \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + +#else + + #define POLYVOX_LOG_DEBUG(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_DEBUG_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(condition); POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + +#endif + +#ifdef POLYVOX_LOG_INFO_ENABLED + + #define POLYVOX_LOG_INFO(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getInfoStreamInstance()) << (message) << std::endl; \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_INFO_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + if ((condition)) \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getInfoStreamInstance()) << (message) << std::endl; \ + } \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + +#else + + #define POLYVOX_LOG_INFO(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_INFO_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(condition); POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + +#endif + +#ifdef POLYVOX_LOG_WARNING_ENABLED + + #define POLYVOX_LOG_WARNING(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getWarningStreamInstance()) << (message) << std::endl; \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_WARNING_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + if ((condition)) \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getWarningStreamInstance()) << (message) << std::endl; \ + } \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + +#else + + #define POLYVOX_LOG_WARNING(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_WARNING_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(condition); POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + +#endif + +#ifdef POLYVOX_LOG_ERROR_ENABLED + + #define POLYVOX_LOG_ERROR(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getErrorStreamInstance()) << (message) << std::endl; \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_ERROR_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + if ((condition)) \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getErrorStreamInstance()) << (message) << std::endl; \ + } \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + +#else + + #define POLYVOX_LOG_ERROR(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_ERROR_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(condition); POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + +#endif + +#ifdef POLYVOX_LOG_FATAL_ENABLED + + #define POLYVOX_LOG_FATAL(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getFatalStreamInstance()) << (message) << std::endl; \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_FATAL_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do \ + { \ + if ((condition)) \ + { \ + /* Appending the 'std::endl' forces the stream to be flushed. */ \ + *(PolyVox::Impl::getFatalStreamInstance()) << (message) << std::endl; \ + } \ + } while(0) \ + POLYVOX_MSC_WARNING_POP + +#else + + #define POLYVOX_LOG_FATAL(message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + + #define POLYVOX_LOG_FATAL_IF(condition, message) \ + /* We use the do...while(0) construct in our macros (for reasons see here: http://stackoverflow.com/a/154138) \ + but Visual Studio gives unhelpful 'conditional expression is constant' warnings. The recommended solution \ + (http://stackoverflow.com/a/1946485) is to disable these warnings. */ \ + POLYVOX_MSC_WARNING_PUSH \ + POLYVOX_DISABLE_MSC_WARNING(4127) \ + do { POLYVOX_UNUSED(condition); POLYVOX_UNUSED(message); } while(0) \ + POLYVOX_MSC_WARNING_POP + +#endif + #endif //__PolyVox_Logging_H__ \ No newline at end of file