Blender  V3.3
log.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #include "util/log.h"
5 
6 #include "util/math.h"
7 #include "util/string.h"
8 
9 #include <stdio.h>
10 #ifdef _MSC_VER
11 # define snprintf _snprintf
12 #endif
13 
15 
16 #ifdef WITH_CYCLES_LOGGING
17 static bool is_verbosity_set()
18 {
19  using CYCLES_GFLAGS_NAMESPACE::GetCommandLineOption;
20 
21  std::string verbosity;
22  if (!GetCommandLineOption("v", &verbosity)) {
23  return false;
24  }
25  return verbosity != "0";
26 }
27 #endif
28 
29 void util_logging_init(const char *argv0)
30 {
31 #ifdef WITH_CYCLES_LOGGING
32  using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption;
33 
34  google::InitGoogleLogging(argv0);
35  SetCommandLineOption("logtostderr", "1");
36  if (!is_verbosity_set()) {
37  SetCommandLineOption("v", "0");
38  }
39  SetCommandLineOption("stderrthreshold", "0");
40  SetCommandLineOption("minloglevel", "0");
41 #else
42  (void)argv0;
43 #endif
44 }
45 
47 {
48 #ifdef WITH_CYCLES_LOGGING
49  using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption;
50  SetCommandLineOption("logtostderr", "1");
51  if (!is_verbosity_set()) {
52  SetCommandLineOption("v", "2");
53  }
54  SetCommandLineOption("stderrthreshold", "0");
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, const int2 &value)
72 {
73  os << "(" << value.x << ", " << value.y << ")";
74  return os;
75 }
76 
77 std::ostream &operator<<(std::ostream &os, const float3 &value)
78 {
79  os << "(" << value.x << ", " << value.y << ", " << value.z << ")";
80  return os;
81 }
82 
#define snprintf
Definition: BLI_winstuff.h:53
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
SyclQueue void void size_t num_bytes void
std::ostream & operator<<(std::ostream &os, const int2 &value)
Definition: log.cpp:71
CCL_NAMESPACE_BEGIN void util_logging_init(const char *argv0)
Definition: log.cpp:29
void util_logging_verbosity_set(int verbosity)
Definition: log.cpp:59
void util_logging_start()
Definition: log.cpp:46
static bool is_verbosity_set()
Definition: logging.cc:10
float z
float y
float x
int x
Definition: types_int2.h:15
int y
Definition: types_int2.h:15