diff options
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/CMakeLists.txt | 18 | ||||
-rw-r--r-- | intern/cycles/app/CMakeLists.txt | 9 | ||||
-rw-r--r-- | intern/cycles/app/cycles_standalone.cpp | 17 | ||||
-rw-r--r-- | intern/cycles/blender/blender_logging.cpp | 38 | ||||
-rw-r--r-- | intern/cycles/cmake/external_libs.cmake | 15 | ||||
-rw-r--r-- | intern/cycles/util/util_logging.cpp | 44 | ||||
-rw-r--r-- | intern/cycles/util/util_logging.h | 4 |
7 files changed, 94 insertions, 51 deletions
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index 56deb8d0ea0..06a6120f41a 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -134,19 +134,11 @@ add_definitions( if(WITH_CYCLES_LOGGING) add_definitions(-DWITH_CYCLES_LOGGING) add_definitions(-DGOOGLE_GLOG_DLL_DECL=) - if(WIN32) - include_directories( - SYSTEM - ../../extern/libmv/third_party/glog/src/windows - ../../extern/libmv/third_party/gflags - ) - else() - include_directories( - SYSTEM - ../../extern/libmv/third_party/glog/src - ../../extern/libmv/third_party/gflags - ) - endif() + include_directories( + SYSTEM + ${GLOG_INCLUDE_DIRS} + ${GFLAGS_INCLUDE_DIRS} + ) endif() # Debugging capabilities (debug passes etc). diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt index 63cd0bca4b4..d48ef51ded4 100644 --- a/intern/cycles/app/CMakeLists.txt +++ b/intern/cycles/app/CMakeLists.txt @@ -37,7 +37,14 @@ if(NOT PUGIXML_LIBRARIES STREQUAL "") list(APPEND LIBRARIES ${PUGIXML_LIBRARIES}) endif() -if(NOT CYCLES_STANDALONE_REPOSITORY) +if(CYCLES_STANDALONE_REPOSITORY) + if(WITH_CYCLES_LOGGING) + list(APPEND LIBRARIES + ${GLOG_LIBRARIES} + ${GFLAGS_LIBRARIES} + ) + endif() +else() list(APPEND LIBRARIES bf_intern_glew_mx) endif() diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp index 1950e0b103f..ce3fb966b8c 100644 --- a/intern/cycles/app/cycles_standalone.cpp +++ b/intern/cycles/app/cycles_standalone.cpp @@ -25,6 +25,7 @@ #include "util_args.h" #include "util_foreach.h" #include "util_function.h" +#include "util_logging.h" #include "util_path.h" #include "util_progress.h" #include "util_string.h" @@ -331,7 +332,8 @@ static void options_parse(int argc, const char **argv) /* parse options */ ArgParse ap; - bool help = false; + bool help = false, debug = false; + int verbosity = 1; ap.options ("Usage: cycles [options] file.xml", "%*", files_parse, "", @@ -347,6 +349,10 @@ static void options_parse(int argc, const char **argv) "--width %d", &options.width, "Window width in pixel", "--height %d", &options.height, "Window height in pixel", "--list-devices", &list, "List information about all available devices", +#ifdef WITH_CYCLES_LOGGING + "--debug", &debug, "Enable debug logging", + "--verbose %d", &verbosity, "Set verbosity of the logger", +#endif "--help", &help, "Print help message", NULL); @@ -355,7 +361,13 @@ static void options_parse(int argc, const char **argv) ap.usage(); exit(EXIT_FAILURE); } - else if(list) { + + if (debug) { + util_logging_start(); + util_logging_verbosity_set(verbosity); + } + + if(list) { vector<DeviceInfo>& devices = Device::available_devices(); printf("Devices:\n"); @@ -435,6 +447,7 @@ using namespace ccl; int main(int argc, const char **argv) { + util_logging_init(argv[0]); path_init(); options_parse(argc, argv); diff --git a/intern/cycles/blender/blender_logging.cpp b/intern/cycles/blender/blender_logging.cpp index 24ec2b4aedd..f4f86929168 100644 --- a/intern/cycles/blender/blender_logging.cpp +++ b/intern/cycles/blender/blender_logging.cpp @@ -15,51 +15,19 @@ */ #include "CCL_api.h" - -#include <stdio.h> - #include "util_logging.h" -#ifdef _MSC_VER -# define snprintf _snprintf -#endif - void CCL_init_logging(const char *argv0) { -#ifdef WITH_CYCLES_LOGGING - /* Make it so FATAL messages are always print into console. */ - char severity_fatal[32]; - snprintf(severity_fatal, sizeof(severity_fatal), "%d", - google::GLOG_FATAL); - - google::InitGoogleLogging(argv0); - gflags::SetCommandLineOption("logtostderr", "1"); - gflags::SetCommandLineOption("v", "0"); - gflags::SetCommandLineOption("stderrthreshold", severity_fatal); - gflags::SetCommandLineOption("minloglevel", severity_fatal); -#else - (void) argv0; -#endif + ccl::util_logging_init(argv0); } void CCL_start_debug_logging(void) { -#ifdef WITH_CYCLES_LOGGING - gflags::SetCommandLineOption("logtostderr", "1"); - gflags::SetCommandLineOption("v", "2"); - gflags::SetCommandLineOption("stderrthreshold", "1"); - gflags::SetCommandLineOption("minloglevel", "0"); -#endif + ccl::util_logging_start(); } void CCL_logging_verbosity_set(int verbosity) { -#ifdef WITH_CYCLES_LOGGING - char val[10]; - snprintf(val, sizeof(val), "%d", verbosity); - - gflags::SetCommandLineOption("v", val); -#else - (void) verbosity; -#endif + ccl::util_logging_verbosity_set(verbosity); } diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake index 537de2e7bc9..465f2d27cf9 100644 --- a/intern/cycles/cmake/external_libs.cmake +++ b/intern/cycles/cmake/external_libs.cmake @@ -109,5 +109,20 @@ if(CYCLES_STANDALONE_REPOSITORY) find_package(LLVM REQUIRED) endif() + #### + # Logging + if(WITH_CYCLES_LOGGING) + find_package(Glog REQUIRED) + find_package(Gflags REQUIRED) + endif() + unset(_lib_DIR) +else() + if(WIN32) + set(GLOG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/libmv/third_party/glog/src/windows) + set(GFLAGS_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/libmv/third_party/gflags) + else() + set(GLOG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/libmv/third_party/glog/src) + set(GFLAGS_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/libmv/third_party/gflags) + endif() endif() diff --git a/intern/cycles/util/util_logging.cpp b/intern/cycles/util/util_logging.cpp index accd8c06d97..1aff647a6bb 100644 --- a/intern/cycles/util/util_logging.cpp +++ b/intern/cycles/util/util_logging.cpp @@ -18,8 +18,52 @@ #include "util_math.h" +#include <stdio.h> +#ifdef _MSC_VER +# define snprintf _snprintf +#endif + CCL_NAMESPACE_BEGIN +void util_logging_init(const char *argv0) +{ +#ifdef WITH_CYCLES_LOGGING + /* Make it so FATAL messages are always print into console. */ + char severity_fatal[32]; + snprintf(severity_fatal, sizeof(severity_fatal), "%d", + google::GLOG_FATAL); + + google::InitGoogleLogging(argv0); + gflags::SetCommandLineOption("logtostderr", "1"); + gflags::SetCommandLineOption("v", "0"); + gflags::SetCommandLineOption("stderrthreshold", severity_fatal); + gflags::SetCommandLineOption("minloglevel", severity_fatal); +#else + (void) argv0; +#endif +} + +void util_logging_start(void) +{ +#ifdef WITH_CYCLES_LOGGING + gflags::SetCommandLineOption("logtostderr", "1"); + gflags::SetCommandLineOption("v", "2"); + gflags::SetCommandLineOption("stderrthreshold", "1"); + gflags::SetCommandLineOption("minloglevel", "0"); +#endif +} + +void util_logging_verbosity_set(int verbosity) +{ +#ifdef WITH_CYCLES_LOGGING + char val[10]; + snprintf(val, sizeof(val), "%d", verbosity); + gflags::SetCommandLineOption("v", val); +#else + (void) verbosity; +#endif +} + std::ostream& operator <<(std::ostream &os, const float3 &value) { diff --git a/intern/cycles/util/util_logging.h b/intern/cycles/util/util_logging.h index 58c7affaef5..7fc42ac355a 100644 --- a/intern/cycles/util/util_logging.h +++ b/intern/cycles/util/util_logging.h @@ -45,6 +45,10 @@ public: struct float3; +void util_logging_init(const char *argv0); +void util_logging_start(void); +void util_logging_verbosity_set(int verbosity); + std::ostream& operator <<(std::ostream &os, const float3 &value); |