diff --git a/CMakeLists.txt b/CMakeLists.txt index 96bf3649..0ea5fbfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,8 @@ foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_TYPE} ${OUTPUT_DIR}) endforeach() -option(GATLING_BUILD_HDGATLING "Build the gatling hydra render delegate." ON) +option(GTL_BUILD_HDGATLING "Build the gatling hydra render delegate." ON) +option(GTL_VERBOSE "Enable verbose logging." OFF) if(${GATLING_BUILD_HDGATLING}) find_package(USD REQUIRED HINTS ${USD_ROOT} NAMES pxr) diff --git a/src/cgpu/impl/Cgpu.cpp b/src/cgpu/impl/Cgpu.cpp index 918eca3e..6c1060a2 100644 --- a/src/cgpu/impl/Cgpu.cpp +++ b/src/cgpu/impl/Cgpu.cpp @@ -27,6 +27,9 @@ #include +#include +#include + #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-variable" @@ -36,12 +39,11 @@ #pragma clang diagnostic ignored "-Wnullability-completeness" #endif -// Uncomment for VMA debug logging -//#define VMA_DEBUG_LOG_FORMAT(format, ...) do { \ -// fprintf(stderr, (format), __VA_ARGS__); \ -// fprintf(stderr, "\n"); \ -// GB_LOG((format), __VA_ARGS__); \ -// } while (false) +#ifdef GTL_VERBOSE +#define VMA_DEBUG_LOG_FORMAT(format, ...) do { \ + GB_DEBUG_DYN("[VMA] {}", GB_FMT_SPRINTF((format), __VA_ARGS__)); \ + } while (false) +#endif #define VMA_IMPLEMENTATION #include diff --git a/src/gb/CMakeLists.txt b/src/gb/CMakeLists.txt index b0e47472..c9442760 100644 --- a/src/gb/CMakeLists.txt +++ b/src/gb/CMakeLists.txt @@ -32,5 +32,9 @@ target_compile_options( ${GTL_COMPILE_OPTIONS} ) +if(GTL_VERBOSE) + target_compile_definitions(gb PUBLIC GTL_VERBOSE=1) +endif() + # Required since library is linked into hdGatling DSO set_target_properties(gb PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/src/gb/gtl/gb/Fmt.h b/src/gb/gtl/gb/Fmt.h index 79182f7e..9630aec0 100644 --- a/src/gb/gtl/gb/Fmt.h +++ b/src/gb/gtl/gb/Fmt.h @@ -18,5 +18,7 @@ #pragma once #include +#include #define GB_FMT(fmt, ...) fmtquill::format(fmt, __VA_ARGS__) +#define GB_FMT_SPRINTF(fmt, ...) fmtquill::sprintf(fmt, __VA_ARGS__) diff --git a/src/gb/gtl/gb/Log.h b/src/gb/gtl/gb/Log.h index 78cf9654..1f27fa59 100644 --- a/src/gb/gtl/gb/Log.h +++ b/src/gb/gtl/gb/Log.h @@ -26,9 +26,11 @@ #include #include -#define GB_LOG(fmt, ...) QUILL_LOG_INFO(gtl::gbGetLogger(), fmt, ##__VA_ARGS__) -#define GB_WARN(fmt, ...) QUILL_LOG_WARNING(gtl::gbGetLogger(), fmt, ##__VA_ARGS__) #define GB_ERROR(fmt, ...) QUILL_LOG_ERROR(gtl::gbGetLogger(), fmt, ##__VA_ARGS__) +#define GB_WARN(fmt, ...) QUILL_LOG_WARNING(gtl::gbGetLogger(), fmt, ##__VA_ARGS__) +#define GB_LOG(fmt, ...) QUILL_LOG_INFO(gtl::gbGetLogger(), fmt, ##__VA_ARGS__) +#define GB_DEBUG(fmt, ...) QUILL_LOG_DEBUG(gtl::gbGetLogger(), fmt, ##__VA_ARGS__) +#define GB_DEBUG_DYN(fmt, ...) QUILL_LOG_DYNAMIC(gtl::gbGetLogger(), quill::LogLevel::Debug, fmt, ##__VA_ARGS__) namespace gtl { diff --git a/src/gb/impl/Log.cpp b/src/gb/impl/Log.cpp index c5cd9721..81c9c3e8 100644 --- a/src/gb/impl/Log.cpp +++ b/src/gb/impl/Log.cpp @@ -39,6 +39,9 @@ namespace gtl const char* logPattern = "[%(time)] (%(log_level)) %(message)"; const char* timestampFormat = "%H:%M:%S.%Qms"; s_logger = quill::Frontend::create_or_get_logger("root", std::move(sink), logPattern, timestampFormat); +#ifdef GTL_VERBOSE + s_logger->set_log_level(quill::LogLevel::Debug); +#endif quill::BackendOptions options; options.thread_name = "GbLog"; diff --git a/src/gi/CMakeLists.txt b/src/gi/CMakeLists.txt index 4c4c7fa2..705b6cb6 100644 --- a/src/gi/CMakeLists.txt +++ b/src/gi/CMakeLists.txt @@ -82,7 +82,7 @@ target_compile_definitions( GI_REF_IMAGE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/testenv" ) -if(${GATLING_BUILD_HDGATLING}) +if(${GTL_BUILD_HDGATLING}) install( FILES "${MDL_SHARED_LIB}" DESTINATION "./hdGatling/resources" diff --git a/src/mc/impl/MdlLogger.cpp b/src/mc/impl/MdlLogger.cpp index c3238b17..3c432d14 100644 --- a/src/mc/impl/MdlLogger.cpp +++ b/src/mc/impl/MdlLogger.cpp @@ -62,9 +62,12 @@ namespace gtl { #ifdef NDEBUG const mi::base::Message_severity minLogLevel = mi::base::MESSAGE_SEVERITY_ERROR; +#elif defined(GTL_VERBOSE) + const mi::base::Message_severity minLogLevel = mi::base::MESSAGE_SEVERITY_INFO; #else const mi::base::Message_severity minLogLevel = mi::base::MESSAGE_SEVERITY_WARNING; #endif + if (level > minLogLevel) { return; @@ -82,15 +85,15 @@ namespace gtl if (level <= mi::base::MESSAGE_SEVERITY_ERROR) { - GB_ERROR("{}", message); + GB_ERROR("[MDL] {}", message); } else if (level <= mi::base::MESSAGE_SEVERITY_WARNING) { - GB_WARN("{}", message); + GB_WARN("[MDL] {}", message); } else { - GB_LOG("{}", message); + GB_DEBUG("[MDL] {}", message); } }