core: Initial implementation for run-time selection of log level

Log level can be controlled using NFD_LOG environment variable. The
following options are available

Set up log level using mnemonic

    NFD_LOG=none|error|warn|info|debug|trace

Set up log level using log-level number (0 none, >=5 all)

    NFD_LOG=0|1|2|3|4|5|6|...

Change-Id: Id38c2775f1137a4e38e4896963ab9a01fc863d2c
Refs: #1267
diff --git a/daemon/core/logger.cpp b/daemon/core/logger.cpp
index 14dd380..928b112 100644
--- a/daemon/core/logger.cpp
+++ b/daemon/core/logger.cpp
@@ -7,14 +7,69 @@
  */
 
 #include "logger.hpp"
+#include <boost/algorithm/string.hpp>
 
-namespace nfd
+namespace nfd {
+
+inline static bool
+isNumber(const std::string& s)
 {
+  if (s.empty())
+    return false;
+
+  for (std::string::const_iterator i = s.begin(); i != s.end(); ++i)
+    {
+      if (!std::isdigit(*i))
+        return false;
+    }
+
+  return true;
+}
 
 Logger::Logger(const std::string& name)
-  : m_moduleName(name),
-    m_isEnabled(true)
+  : m_moduleName(name)
 {
+  char* nfdLog = getenv("NFD_LOG");
+  if (nfdLog)
+    {
+      std::string level = nfdLog;
+      if (isNumber(nfdLog))
+        {
+          setLogLevel(boost::lexical_cast<uint32_t>(nfdLog));
+        }
+      else if (boost::iequals(level, "none"))
+        {
+          m_enabledLogLevel = LOG_NONE;
+        }
+      else if (boost::iequals(level, "error"))
+        {
+          m_enabledLogLevel = LOG_ERROR;
+        }
+      else if (boost::iequals(level, "warn"))
+        {
+          m_enabledLogLevel = LOG_WARN;
+        }
+      else if (boost::iequals(level, "info"))
+        {
+          m_enabledLogLevel = LOG_INFO;
+        }
+      else if (boost::iequals(level, "debug"))
+        {
+          m_enabledLogLevel = LOG_DEBUG;
+        }
+      else if (boost::iequals(level, "trace"))
+        {
+          m_enabledLogLevel = LOG_TRACE;
+        }
+      else
+        {
+          m_enabledLogLevel = LOG_ALL;
+        }
+    }
+  else
+    {
+      m_enabledLogLevel = LOG_WARN;
+    }
 }
 
 std::ostream&