Cycles: Make all #include statements relative to cycles source directory
[blender.git] / intern / cycles / util / util_logging.cpp
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 #include "util/util_logging.h"
18
19 #include "util/util_math.h"
20
21 #include <stdio.h>
22 #ifdef _MSC_VER
23 #  define snprintf _snprintf
24 #endif
25
26 CCL_NAMESPACE_BEGIN
27
28 void util_logging_init(const char *argv0)
29 {
30 #ifdef WITH_CYCLES_LOGGING
31         using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption;
32
33         /* Make it so FATAL messages are always print into console. */
34         char severity_fatal[32];
35         snprintf(severity_fatal, sizeof(severity_fatal), "%d",
36                  google::GLOG_FATAL);
37
38         google::InitGoogleLogging(argv0);
39         SetCommandLineOption("logtostderr", "1");
40         SetCommandLineOption("v", "0");
41         SetCommandLineOption("stderrthreshold", severity_fatal);
42         SetCommandLineOption("minloglevel", severity_fatal);
43 #else
44         (void) argv0;
45 #endif
46 }
47
48 void util_logging_start(void)
49 {
50 #ifdef WITH_CYCLES_LOGGING
51         using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption;
52         SetCommandLineOption("logtostderr", "1");
53         SetCommandLineOption("v", "2");
54         SetCommandLineOption("stderrthreshold", "1");
55         SetCommandLineOption("minloglevel", "0");
56 #endif
57 }
58
59 void util_logging_verbosity_set(int verbosity)
60 {
61 #ifdef WITH_CYCLES_LOGGING
62         using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption;
63         char val[10];
64         snprintf(val, sizeof(val), "%d", verbosity);
65         SetCommandLineOption("v", val);
66 #else
67         (void) verbosity;
68 #endif
69 }
70
71 std::ostream& operator <<(std::ostream &os,
72                           const int2 &value)
73 {
74         os << "(" << value.x
75            << ", " << value.y
76            << ")";
77         return os;
78 }
79
80 std::ostream& operator <<(std::ostream &os,
81                           const float3 &value)
82 {
83         os << "(" << value.x
84            << ", " << value.y
85            << ", " << value.z
86            << ")";
87         return os;
88 }
89
90 CCL_NAMESPACE_END