Blender V4.3
log.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#include "util/log.h"
6
7#include "util/math.h"
8#include "util/string.h"
9
10#include <stdio.h>
11#ifdef _MSC_VER
12# define snprintf _snprintf
13#endif
14
16
17#ifdef WITH_CYCLES_LOGGING
18static bool is_verbosity_set()
19{
20 using CYCLES_GFLAGS_NAMESPACE::GetCommandLineOption;
21
22 std::string verbosity;
23 if (!GetCommandLineOption("v", &verbosity)) {
24 return false;
25 }
26 return verbosity != "0";
27}
28#endif
29
30void util_logging_init(const char *argv0)
31{
32#ifdef WITH_CYCLES_LOGGING
33 using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption;
34
35 google::InitGoogleLogging(argv0);
36 SetCommandLineOption("logtostderr", "1");
37 if (!is_verbosity_set()) {
38 SetCommandLineOption("v", "0");
39 }
40 SetCommandLineOption("stderrthreshold", "0");
41 SetCommandLineOption("minloglevel", "0");
42#else
43 (void)argv0;
44#endif
45}
46
48{
49#ifdef WITH_CYCLES_LOGGING
50 using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption;
51 SetCommandLineOption("logtostderr", "1");
52 if (!is_verbosity_set()) {
53 SetCommandLineOption("v", "2");
54 }
55 SetCommandLineOption("stderrthreshold", "0");
56 SetCommandLineOption("minloglevel", "0");
57#endif
58}
59
60void util_logging_verbosity_set(int verbosity)
61{
62#ifdef WITH_CYCLES_LOGGING
63 using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption;
64 char val[10];
65 snprintf(val, sizeof(val), "%d", verbosity);
66 SetCommandLineOption("v", val);
67#else
68 (void)verbosity;
69#endif
70}
71
72std::ostream &operator<<(std::ostream &os, const int2 &value)
73{
74 os << "(" << value.x << ", " << value.y << ")";
75 return os;
76}
77
78std::ostream &operator<<(std::ostream &os, const float3 &value)
79{
80 os << "(" << value.x << ", " << value.y << ", " << value.z << ")";
81 return os;
82}
83
#define CCL_NAMESPACE_END
std::ostream & operator<<(std::ostream &os, const int2 &value)
Definition log.cpp:72
CCL_NAMESPACE_BEGIN void util_logging_init(const char *argv0)
Definition log.cpp:30
void util_logging_verbosity_set(int verbosity)
Definition log.cpp:60
void util_logging_start()
Definition log.cpp:47
static bool is_verbosity_set()
Definition logging.cc:11