diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-11-15 23:12:19 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-12-31 23:31:07 +0300 |
commit | bbf12722edb7d1cfbbdedd6757275ff386211fe0 (patch) | |
tree | caf5c11413443ca2e0e3060fa65e413271ce2be1 /intern/cycles/util/util_logging.cpp | |
parent | f2665d52e220a7726f1ca84127a1d1fb8078f521 (diff) |
Cycles: Fully support WITH_CYCLES_LOGGING option
This commit generalizes logging module a little bit in making it possible to use
Glog logging in standalone Cycles repository.
Diffstat (limited to 'intern/cycles/util/util_logging.cpp')
-rw-r--r-- | intern/cycles/util/util_logging.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
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) { |