Fixing issue where default_logger.h conflates LOG and VLOG. Issue reported and original idea for a fix provided by ben.darnell.

git-svn-id: http://libphonenumber.googlecode.com/svn/trunk/cpp/src/phonenumbers@599 ee073f10-1060-11df-b6a4-87a95322a99c
diff --git a/default_logger.cc b/default_logger.cc
index 44379a5..c54b640 100644
--- a/default_logger.cc
+++ b/default_logger.cc
@@ -29,18 +29,27 @@
 }
 
 void StdoutLogger::WriteLevel() {
-  LogLevel log_level = level();
+  int verbosity_level = level();
+  if (verbosity_level <= 0) {
+    verbosity_level = LOG_FATAL;
+  }
+
   cout << "[";
 
-  switch (log_level) {
-    case LOG_FATAL:   cout << "FATAL"; break;
+  // Handle verbose logs first.
+  if (verbosity_level > LOG_DEBUG) {
+    cout << "VLOG" << (verbosity_level - LOG_DEBUG);
+  } else {
+    switch (verbosity_level) {
+      case LOG_FATAL:   cout << "FATAL"; break;
 #ifdef ERROR  // In case ERROR is defined by MSVC (i.e not set to LOG_ERROR).
-    case ERROR:
+      case ERROR:
 #endif
-    case LOG_ERROR:   cout << "ERROR"; break;
-    case LOG_WARNING: cout << "WARNING"; break;
-    case LOG_INFO:    cout << "INFO"; break;
-    case LOG_DEBUG:   cout << "DEBUG"; break;
+      case LOG_ERROR:   cout << "ERROR"; break;
+      case LOG_WARNING: cout << "WARNING"; break;
+      case LOG_INFO:    cout << "INFO"; break;
+      case LOG_DEBUG:   cout << "DEBUG"; break;
+    }
   }
   cout << "]";
 }
diff --git a/default_logger.h b/default_logger.h
index afb6fc9..25754d7 100644
--- a/default_logger.h
+++ b/default_logger.h
@@ -74,7 +74,7 @@
   Logger* const impl_;
 };
 
-inline LoggerHandler VLOG(int n) {
+inline LoggerHandler LOG(int n) {
   Logger* const logger_impl = Logger::mutable_logger_impl();
   if (logger_impl->level() < n) {
     return LoggerHandler(NULL);
@@ -83,8 +83,10 @@
   return LoggerHandler(logger_impl);
 }
 
-inline LoggerHandler LOG(int n) {
-  return VLOG(n);
+inline LoggerHandler VLOG(int n) {
+  // VLOG(1) is the next logging level after LOG(DEBUG).
+  n += LOG_DEBUG;
+  return LOG(n);
 }
 
 // Default logger implementation used by PhoneNumberUtil class. It outputs the
diff --git a/logger.h b/logger.h
index 4a6d23b..9d67f91 100644
--- a/logger.h
+++ b/logger.h
@@ -25,7 +25,7 @@
 
 using std::string;
 
-enum LogLevel {
+enum {
   LOG_FATAL = 1,
   LOG_ERROR,
   LOG_WARNING,
@@ -54,14 +54,26 @@
   // Writes the provided message to the underlying output stream.
   virtual void WriteMessage(const string& msg) = 0;
 
-  inline LogLevel level() const {
+  // Note that if set_verbosity_level has been used to set the level to a value
+  // that is not represented by an enum, the result here will be a log
+  // level that is higher than LOG_DEBUG.
+  inline int level() const {
     return level_;
   }
 
-  inline void set_level(LogLevel level) {
+  inline void set_level(int level) {
     level_ = level;
   }
 
+  // If you want to see verbose logs in addition to other logs, use this method.
+  // This will result in all log messages at the levels above being shown, along
+  // with calls to VLOG with the verbosity level set to this level or lower.
+  // For example, set_verbosity_level(2) will show calls of VLOG(1) and VLOG(2)
+  // but not VLOG(3), along with all calls to LOG().
+  inline void set_verbosity_level(int verbose_logs_level) {
+    set_level(LOG_DEBUG + verbose_logs_level);
+  }
+
   static inline Logger* set_logger_impl(Logger* logger) {
     impl_ = logger;
     return logger;
@@ -73,7 +85,7 @@
 
  private:
   static Logger* impl_;
-  LogLevel level_;
+  int level_;
 };
 
 // Logger that does not log anything. It could be useful to "mute" the