Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-09-08 16:01:24 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-09-25 15:08:32 +0400
commit13d8671a1a71e77ca3c6b1ce3d13d200ddd778d1 (patch)
treed8a02a2b1601b5bff66d2b2a6987ecccc33e9dd1 /intern/cycles/blender
parent058e3f087e4db827e0dcb2b8ea662fa7cdc1ff6b (diff)
Cycles: Add support of Glog logging
This commit makes it possible to use Glog library for the debug logging. For now only possible when using CMake and in order to use the logging the WITH_CYCLES_LOGGING configuration variable is to be enabled. When this option is not enabled or when using Scons there's no difference in Cycles behavior at all, when using logging and no output to the console impact is gonna to be minimal. This is done in order to make it possible to have debug logging persistent in code (without need to add it when troubleshooting some bug and removing it afterwards). For now actual logging is not placed yet, only all the functions needed for the logging are written and so.
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/CCL_api.h4
-rw-r--r--intern/cycles/blender/CMakeLists.txt1
-rw-r--r--intern/cycles/blender/blender_logging.cpp65
3 files changed, 70 insertions, 0 deletions
diff --git a/intern/cycles/blender/CCL_api.h b/intern/cycles/blender/CCL_api.h
index 2772b9ac8a7..cfd0c3ef264 100644
--- a/intern/cycles/blender/CCL_api.h
+++ b/intern/cycles/blender/CCL_api.h
@@ -36,6 +36,10 @@ CCLDeviceInfo *CCL_compute_device_list(int device_type);
void *CCL_python_module_init(void);
+void CCL_init_logging(const char *argv0);
+void CCL_start_debug_logging(void);
+void CCL_logging_verbosity_set(int verbosity);
+
#ifdef __cplusplus
}
#endif
diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt
index 548aac85af9..13ac0be0562 100644
--- a/intern/cycles/blender/CMakeLists.txt
+++ b/intern/cycles/blender/CMakeLists.txt
@@ -25,6 +25,7 @@ set(SRC
blender_object.cpp
blender_particles.cpp
blender_curves.cpp
+ blender_logging.cpp
blender_python.cpp
blender_session.cpp
blender_shader.cpp
diff --git a/intern/cycles/blender/blender_logging.cpp b/intern/cycles/blender/blender_logging.cpp
new file mode 100644
index 00000000000..d3f1accf099
--- /dev/null
+++ b/intern/cycles/blender/blender_logging.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011-2014 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#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);
+ google::SetCommandLineOption("logtostderr", "1");
+ google::SetCommandLineOption("v", "0");
+ google::SetCommandLineOption("stderrthreshold", severity_fatal);
+ google::SetCommandLineOption("minloglevel", severity_fatal);
+#else
+ (void) argv0;
+#endif
+}
+
+void CCL_start_debug_logging(void)
+{
+#ifdef WITH_CYCLES_LOGGING
+ google::SetCommandLineOption("logtostderr", "1");
+ google::SetCommandLineOption("v", "2");
+ google::SetCommandLineOption("stderrthreshold", "1");
+ google::SetCommandLineOption("minloglevel", "0");
+#endif
+}
+
+void CCL_logging_verbosity_set(int verbosity)
+{
+#ifdef WITH_CYCLES_LOGGING
+ char val[10];
+ snprintf(val, sizeof(val), "%d", verbosity);
+
+ google::SetCommandLineOption("v", val);
+#else
+ (void) verbosity;
+#endif
+}