From 13d8671a1a71e77ca3c6b1ce3d13d200ddd778d1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 8 Sep 2014 18:01:24 +0600 Subject: 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. --- intern/cycles/util/CMakeLists.txt | 2 ++ intern/cycles/util/util_logging.cpp | 33 +++++++++++++++++++++++ intern/cycles/util/util_logging.h | 53 +++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 intern/cycles/util/util_logging.cpp create mode 100644 intern/cycles/util/util_logging.h (limited to 'intern/cycles/util') 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 + +#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 +#else +# include +#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__ */ -- cgit v1.2.3