Add --v switch into example code
Change-Id: I872dd0d910ec892a8ed23220fe66db49984f8ec0
Reviewed-on: https://weave-review.googlesource.com/1281
Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/libweave/examples/ubuntu/main.cc b/libweave/examples/ubuntu/main.cc
index 5a7c2fa..0891e01 100644
--- a/libweave/examples/ubuntu/main.cc
+++ b/libweave/examples/ubuntu/main.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <bitset>
+
#include <base/bind.h>
#include <base/values.h>
#include <weave/device.h>
@@ -25,6 +26,7 @@
LOG(ERROR) << "\nUsage: " << name << " <option(s)>"
<< "\nOptions:\n"
<< "\t-h,--help Show this help message\n"
+ << "\t--v=LEVEL Logging level\n"
<< "\t-b,--bootstrapping Force WiFi bootstrapping\n"
<< "\t-d,--disable_security Disable privet security\n"
<< "\t--registration_ticket=TICKET Register device with the "
@@ -249,6 +251,13 @@
return 1;
}
registration_ticket = arg.substr(pos + 1);
+ } else if (arg.find("--v") != std::string::npos) {
+ auto pos = arg.find("=");
+ if (pos == std::string::npos) {
+ ShowUsage(argv[0]);
+ return 1;
+ }
+ logging::SetMinLogLevel(-std::stoi(arg.substr(pos + 1)));
} else {
ShowUsage(argv[0]);
return 1;
diff --git a/libweave/external/base/logging.cc b/libweave/external/base/logging.cc
index c576d18..1fd047f 100644
--- a/libweave/external/base/logging.cc
+++ b/libweave/external/base/logging.cc
@@ -83,11 +83,6 @@
return std::max(-1, LOG_INFO - GetMinLogLevel());
}
-int GetVlogLevelHelper(const char* file, size_t N) {
- DCHECK_GT(N, 0U);
- return 0;
-}
-
void SetLogItems(bool enable_process_id, bool enable_thread_id,
bool enable_timestamp, bool enable_tickcount) {
g_log_timestamp = enable_timestamp;
diff --git a/libweave/external/base/logging.h b/libweave/external/base/logging.h
index 0096d9d..61e9f9d 100644
--- a/libweave/external/base/logging.h
+++ b/libweave/external/base/logging.h
@@ -195,7 +195,9 @@
// __FILE__).
// Note that |N| is the size *with* the null terminator.
-int GetVlogLevelHelper(const char* file_start, size_t N);
+inline int GetVlogLevelHelper(const char* file_start, size_t N) {
+ return GetVlogVerbosity();
+}
template <size_t N>
int GetVlogLevel(const char (&file)[N]) {