diff options
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/CMakeLists.txt | 18 | ||||
-rw-r--r-- | intern/cycles/blender/CCL_api.h | 4 | ||||
-rw-r--r-- | intern/cycles/blender/CMakeLists.txt | 1 | ||||
-rw-r--r-- | intern/cycles/blender/blender_logging.cpp | 65 | ||||
-rw-r--r-- | intern/cycles/util/CMakeLists.txt | 2 | ||||
-rw-r--r-- | intern/cycles/util/util_logging.cpp | 33 | ||||
-rw-r--r-- | intern/cycles/util/util_logging.h | 53 |
7 files changed, 176 insertions, 0 deletions
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index ccf6aac945e..bfd29dcf606 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -128,6 +128,24 @@ add_definitions( -DWITH_MULTI ) +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() +endif() + include_directories( SYSTEM ${BOOST_INCLUDE_DIR} 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 +} diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt index d9b97a7f6b0..6120e7e8456 100644 --- a/intern/cycles/util/CMakeLists.txt +++ b/intern/cycles/util/CMakeLists.txt @@ -11,6 +11,7 @@ set(INC_SYS set(SRC util_cache.cpp util_dynlib.cpp + util_logging.cpp util_md5.cpp util_path.cpp util_string.cpp @@ -40,6 +41,7 @@ set(SRC_HEADERS util_hash.h util_image.h util_list.h + util_logging.h util_map.h util_math.h util_md5.h diff --git a/intern/cycles/util/util_logging.cpp b/intern/cycles/util/util_logging.cpp new file mode 100644 index 00000000000..0722f16cf45 --- /dev/null +++ b/intern/cycles/util/util_logging.cpp @@ -0,0 +1,33 @@ +/* + * 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 <util_logging.h> + +#include "util_math.h" + +CCL_NAMESPACE_BEGIN + +std::ostream& operator <<(std::ostream &os, + const float3 &value) +{ + os << "(" << value.x + << ", " << value.y + << ", " << value.z + << ")"; + return os; +} + +CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_logging.h b/intern/cycles/util/util_logging.h new file mode 100644 index 00000000000..2bd0fac7fa6 --- /dev/null +++ b/intern/cycles/util/util_logging.h @@ -0,0 +1,53 @@ +/* + * 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 + */ + +#ifndef __UTIL_LOGGING_H__ +#define __UTIL_LOGGING_H__ + +#if defined(WITH_CYCLES_LOGGING) && !defined(__KERNEL_GPU__) +# include <glog/logging.h> +#else +# include <iostream> +#endif + +CCL_NAMESPACE_BEGIN + +#if !defined(WITH_CYCLES_LOGGING) || defined(__KERNEL_GPU__) +class StubStream : public std::ostream { + public: + StubStream () { } +}; + +class LogMessageVoidify { +public: + LogMessageVoidify() { } + void operator&(::std::ostream&) { } +}; + +# define LOG_SUPPRESS() (true) ? (void) 0 : LogMessageVoidify() & StubStream() +# define LOG(severity) LOG_SUPPRESS() +# define VLOG(severity) LOG_SUPPRESS() + +#endif + +class float3; + +std::ostream& operator <<(std::ostream &os, + const float3 &value); + +CCL_NAMESPACE_END + +#endif /* __UTIL_LOGGING_H__ */ |