src: Make log-level in nlsr.conf optional

refs: #2335

Change-Id: I185b6200ad1d7f16e3ca4b646ec20af83f983787
diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp
index 21940d6..37cb2b4 100644
--- a/src/conf-file-processor.cpp
+++ b/src/conf-file-processor.cpp
@@ -294,20 +294,15 @@
     return false;
   }
 
-  try {
-    std::string logLevel = section.get<string>("log-level");
+  // log-level
+  std::string logLevel = section.get<string>("log-level", "INFO");
 
-    if (isValidLogLevel(logLevel)) {
-      m_nlsr.getConfParameter().setLogLevel(logLevel);
-    }
-    else {
-      std::cerr << "Invalid value for log-level ";
-      std::cerr << "Valid values: ALL, TRACE, DEBUG, INFO, WARN, ERROR, NONE" << std::endl;
-      return false;
-    }
+  if (isValidLogLevel(logLevel)) {
+    m_nlsr.getConfParameter().setLogLevel(logLevel);
   }
-  catch (const std::exception& ex) {
-    std::cerr << ex.what() << std::endl;
+  else {
+    std::cerr << "Invalid value for log-level ";
+    std::cerr << "Valid values: ALL, TRACE, DEBUG, INFO, WARN, ERROR, NONE" << std::endl;
     return false;
   }
 
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index 817f149..653faa3 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -377,6 +377,7 @@
   commentOut("lsa-refresh-time", config);
   commentOut("lsa-interest-lifetime", config);
   commentOut("router-dead-interval", config);
+  commentOut("log-level", config);
 
   BOOST_CHECK_EQUAL(processConfigurationString(config), true);
 
@@ -386,6 +387,7 @@
   BOOST_CHECK_EQUAL(conf.getLsaInterestLifetime(),
                     static_cast<ndn::time::seconds>(LSA_INTEREST_LIFETIME_DEFAULT));
   BOOST_CHECK_EQUAL(conf.getRouterDeadInterval(), (2*conf.getLsaRefreshTime()));
+  BOOST_CHECK_EQUAL(conf.getLogLevel(), "INFO");
 }
 
 BOOST_AUTO_TEST_CASE(DefaultValuesNeighbors)