1 /*
2  * Copyright 2011-2014 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __UTIL_LOGGING_H__
18 #define __UTIL_LOGGING_H__
19 
20 #if defined(WITH_CYCLES_LOGGING) && !defined(__KERNEL_GPU__)
21 #  include <gflags/gflags.h>
22 #  include <glog/logging.h>
23 #endif
24 
25 #include <iostream>
26 
27 CCL_NAMESPACE_BEGIN
28 
29 #if !defined(WITH_CYCLES_LOGGING) || defined(__KERNEL_GPU__)
30 class StubStream {
31  public:
32   template<class T> StubStream &operator<<(const T &)
33   {
34     return *this;
35   }
36 };
37 
38 class LogMessageVoidify {
39  public:
LogMessageVoidify()40   LogMessageVoidify()
41   {
42   }
43   void operator&(StubStream &)
44   {
45   }
46 };
47 
48 #  define LOG_SUPPRESS() (true) ? ((void)0) : LogMessageVoidify() & StubStream()
49 #  define LOG(severity) LOG_SUPPRESS()
50 #  define VLOG(severity) LOG_SUPPRESS()
51 #  define VLOG_IF(severity, condition) LOG_SUPPRESS()
52 #endif
53 
54 #define VLOG_ONCE(level, flag) \
55   if (!flag) \
56   flag = true, VLOG(level)
57 
58 struct int2;
59 struct float3;
60 
61 void util_logging_init(const char *argv0);
62 void util_logging_start();
63 void util_logging_verbosity_set(int verbosity);
64 
65 std::ostream &operator<<(std::ostream &os, const int2 &value);
66 std::ostream &operator<<(std::ostream &os, const float3 &value);
67 
68 CCL_NAMESPACE_END
69 
70 #endif /* __UTIL_LOGGING_H__ */
71