Blender  V2.93
logging.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2011 Blender Foundation.
17  * All rights reserved.
18  */
19 
20 #include <gflags/gflags.h>
21 
22 #include "intern/logging.h"
23 #include "intern/utildefines.h"
24 #include "libmv/logging/logging.h"
25 
26 static bool is_verbosity_set() {
27  using LIBMV_GFLAGS_NAMESPACE::GetCommandLineOption;
28 
29  std::string verbosity;
30  if (!GetCommandLineOption("v", &verbosity)) {
31  return false;
32  }
33  return verbosity != "0";
34 }
35 
36 void libmv_initLogging(const char* argv0) {
37  using LIBMV_GFLAGS_NAMESPACE::SetCommandLineOption;
38  google::InitGoogleLogging(argv0);
39  SetCommandLineOption("logtostderr", "1");
40  if (!is_verbosity_set()) {
41  SetCommandLineOption("v", "0");
42  }
43  SetCommandLineOption("stderrthreshold", "0");
44  SetCommandLineOption("minloglevel", "0");
45 }
46 
48  using LIBMV_GFLAGS_NAMESPACE::SetCommandLineOption;
49  SetCommandLineOption("logtostderr", "1");
50  if (!is_verbosity_set()) {
51  SetCommandLineOption("v", "2");
52  }
53  SetCommandLineOption("stderrthreshold", "0");
54  SetCommandLineOption("minloglevel", "0");
55 }
56 
57 void libmv_setLoggingVerbosity(int verbosity) {
58  using LIBMV_GFLAGS_NAMESPACE::SetCommandLineOption;
59  char val[10];
60  snprintf(val, sizeof(val), "%d", verbosity);
61  SetCommandLineOption("v", val);
62 }
#define snprintf
Definition: BLI_winstuff.h:69
void libmv_setLoggingVerbosity(int verbosity)
Definition: logging.cc:57
void libmv_startDebugLogging(void)
Definition: logging.cc:47
void libmv_initLogging(const char *argv0)
Definition: logging.cc:36
static bool is_verbosity_set()
Definition: logging.cc:26