Use ndn-cxx logging facility

refs: #3949

Change-Id: I5d0931c3576c88e0c2fa52bdd0a716946400e0bc
diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index 896e7b3..dd733fa 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -50,7 +50,6 @@
     , lsdb(nlsr.getLsdb())
     , rt1(nlsr.getRoutingTable())
   {
-    INIT_LOGGERS("/tmp/", "TRACE");
     nlsr.getConfParameter().setNetwork("/ndn");
     nlsr.getConfParameter().setRouterName("/This/Router");
 
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index 0400b05..2249dab 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -21,7 +21,6 @@
 
 #include "conf-file-processor.hpp"
 #include "test-common.hpp"
-#include "logger.hpp"
 #include "nlsr.hpp"
 
 #include <fstream>
@@ -45,28 +44,9 @@
   "  lsa-refresh-time 1800\n"
   "  lsa-interest-lifetime 3\n"
   "  router-dead-interval 86400\n"
-  "  log-level  INFO\n"
-  "  log-dir /tmp\n"
   "  seq-dir /tmp\n"
   "}\n\n";
 
-const std::string LOG4CXX_PLACEHOLDER = "$LOG4CXX$";
-
-const std::string SECTION_GENERAL_WITH_LOG4CXX =
-  "general\n"
-  "{\n"
-  "  network /ndn/\n"
-  "  site /memphis.edu/\n"
-  "  router /cs/pollux/\n"
-  "  lsa-refresh-time 1800\n"
-  "  lsa-interest-lifetime 3\n"
-  "  router-dead-interval 86400\n"
-  "  log-level  INFO\n"
-  "  log-dir /tmp\n"
-  "  seq-dir /tmp\n"
-  "  log4cxx-conf " + LOG4CXX_PLACEHOLDER + "\n"
-  "}\n\n";
-
 const std::string SECTION_NEIGHBORS =
   "neighbors\n"
   "{\n"
@@ -130,8 +110,6 @@
 const std::string CONFIG_LINK_STATE = SECTION_GENERAL + SECTION_NEIGHBORS +
                                       SECTION_HYPERBOLIC_OFF + SECTION_FIB + SECTION_ADVERTISING;
 
-const std::string CONFIG_LOG4CXX = SECTION_GENERAL_WITH_LOG4CXX;
-
 const std::string CONFIG_HYPERBOLIC = SECTION_GENERAL + SECTION_NEIGHBORS +
                                       SECTION_HYPERBOLIC_ON + SECTION_FIB + SECTION_ADVERTISING;
 
@@ -146,18 +124,12 @@
     : face(m_ioService, m_keyChain)
     , nlsr(m_ioService, m_scheduler, face, m_keyChain)
     , CONFIG_FILE("unit-test-nlsr.conf")
-    , m_logConfigFileName(boost::filesystem::unique_path().string())
-    , m_logFileName(boost::filesystem::unique_path().string())
   {
   }
 
   ~ConfFileProcessorFixture()
   {
     remove("unit-test-nlsr.conf");
-    remove("/tmp/unit-test-log4cxx.xml");
-
-    boost::filesystem::remove(boost::filesystem::path(getLogConfigFileName()));
-    boost::filesystem::remove(boost::filesystem::path(getLogFileName()));
   }
 
   bool
@@ -173,39 +145,6 @@
   }
 
   void
-  verifyOutputLog4cxx(const std::string expected[], size_t nExpected)
-  {
-    std::ifstream is(getLogFileName().c_str());
-    std::string buffer((std::istreambuf_iterator<char>(is)),
-                       (std::istreambuf_iterator<char>()));
-
-    std::vector<std::string> components;
-    boost::split(components, buffer, boost::is_any_of(" ,\n"));
-
-    // expected + number of timestamps (one per log statement) + trailing newline of last statement
-    BOOST_REQUIRE_EQUAL(components.size(), nExpected);
-
-    for (size_t i = 0; i < nExpected; ++i) {
-      if (expected[i] == "")
-        continue;
-
-      BOOST_CHECK_EQUAL(components[i], expected[i]);
-    }
-  }
-
-  const std::string&
-  getLogConfigFileName()
-  {
-    return m_logConfigFileName;
-  }
-
-  const std::string&
-  getLogFileName()
-  {
-    return m_logFileName;
-  }
-
-  void
   commentOut(const std::string& key, std::string& config)
   {
     boost::replace_all(config, key, ";" + key);
@@ -217,8 +156,6 @@
 
 private:
   const std::string CONFIG_FILE;
-  std::string m_logConfigFileName;
-  std::string m_logFileName;
 };
 
 BOOST_FIXTURE_TEST_SUITE(TestConfFileProcessor, ConfFileProcessorFixture)
@@ -239,8 +176,6 @@
   BOOST_CHECK_EQUAL(conf.getLsaRefreshTime(), 1800);
   BOOST_CHECK_EQUAL(conf.getLsaInterestLifetime(), ndn::time::seconds(3));
   BOOST_CHECK_EQUAL(conf.getRouterDeadInterval(), 86400);
-  BOOST_CHECK_EQUAL(conf.getLogLevel(), "INFO");
-  BOOST_CHECK_EQUAL(conf.getLogDir(), "/tmp");
   BOOST_CHECK_EQUAL(conf.getSeqFileDir(), "/tmp");
 
   // Neighbors
@@ -274,81 +209,6 @@
   BOOST_CHECK_EQUAL(nlsr.getNamePrefixList().size(), 2);
 }
 
-BOOST_AUTO_TEST_CASE(Log4cxxFileExists)
-{
-  std::string configPath = boost::filesystem::unique_path().native();
-
-  std::ofstream log4cxxConfFile;
-  log4cxxConfFile.open(configPath);
-  log4cxxConfFile.close();
-
-  std::string config = CONFIG_LOG4CXX;
-  boost::replace_all(config, LOG4CXX_PLACEHOLDER, configPath);
-
-  BOOST_CHECK_EQUAL(processConfigurationString(config), true);
-
-  ConfParameter& conf = nlsr.getConfParameter();
-  BOOST_CHECK_EQUAL(conf.getLog4CxxConfPath(), configPath);
-  BOOST_CHECK_EQUAL(conf.isLog4CxxConfAvailable(), true);
-
-  boost::filesystem::remove(boost::filesystem::path(configPath));
-}
-
-BOOST_AUTO_TEST_CASE(Log4cxxFileDoesNotExist)
-{
-  std::string configPath = boost::filesystem::unique_path().native();
-
-  std::string config = CONFIG_LOG4CXX;
-  boost::replace_all(config, LOG4CXX_PLACEHOLDER, configPath);
-
-  BOOST_CHECK_EQUAL(processConfigurationString(config), false);
-}
-
-BOOST_AUTO_TEST_CASE(Log4cxxNoValue)
-{
-  std::string config = CONFIG_LOG4CXX;
-  boost::replace_all(config, LOG4CXX_PLACEHOLDER, "");
-
-  BOOST_CHECK_EQUAL(processConfigurationString(config), false);
-}
-
-BOOST_AUTO_TEST_CASE(Log4cxxTestCase)
-{
-  {
-    std::ofstream of(getLogConfigFileName().c_str());
-    of << "log4j.rootLogger=TRACE, FILE\n"
-       << "log4j.appender.FILE=org.apache.log4j.FileAppender\n"
-       << "log4j.appender.FILE.layout=org.apache.log4j.PatternLayout\n"
-       << "log4j.appender.FILE.File=" << getLogFileName() << "\n"
-       << "log4j.appender.FILE.ImmediateFlush=true\n"
-       << "log4j.appender.FILE.layout.ConversionPattern=%d{HH:mm:ss} %p %c{1} - %m%n\n";
-  }
-
-  INIT_LOG4CXX(getLogConfigFileName());
-
-  INIT_LOGGER("DefaultConfig");
-
-  NLSR_LOG_TRACE("trace-message-JHGFDSR^1");
-  NLSR_LOG_DEBUG("debug-message-IGg2474fdksd-fo-" << 15 << 16 << 17);
-  NLSR_LOG_INFO("info-message-Jjxjshj13");
-  NLSR_LOG_WARN("warning-message-XXXhdhd11" << 1 <<"x");
-  NLSR_LOG_ERROR("error-message-!#$&^%$#@");
-  NLSR_LOG_FATAL("fatal-message-JJSjaamcng");
-
-  const std::string EXPECTED[] =
-    {
-      "", "TRACE", "DefaultConfig", "-", "trace-message-JHGFDSR^1",
-      "", "DEBUG", "DefaultConfig", "-", "debug-message-IGg2474fdksd-fo-151617",
-      "", "INFO",  "DefaultConfig", "-", "info-message-Jjxjshj13",
-      "", "WARN",  "DefaultConfig", "-", "warning-message-XXXhdhd111x",
-      "", "ERROR", "DefaultConfig", "-", "error-message-!#$&^%$#@",
-      "", "FATAL", "DefaultConfig", "-", "fatal-message-JJSjaamcng",
-      "",
-    };
-
-  verifyOutputLog4cxx(EXPECTED, sizeof(EXPECTED) / sizeof(std::string));
-}
-
 BOOST_AUTO_TEST_CASE(MalformedUri)
 {
   const std::string MALFORMED_URI =
@@ -402,7 +262,6 @@
   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);
 
@@ -412,7 +271,6 @@
   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)
diff --git a/tests/test-fib.cpp b/tests/test-fib.cpp
index 80408eb..d47d3a8 100644
--- a/tests/test-fib.cpp
+++ b/tests/test-fib.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -39,8 +39,6 @@
     : face(std::make_shared<ndn::util::DummyClientFace>(m_keyChain))
     , interests(face->sentInterests)
   {
-    INIT_LOGGERS("/tmp", "DEBUG");
-
     Adjacent neighbor1(router1Name, ndn::FaceUri(router1FaceUri), 0, Adjacent::STATUS_ACTIVE, 0, router1FaceId);
     adjacencies.insert(neighbor1);
 
diff --git a/tests/test-hyperbolic-calculator.cpp b/tests/test-hyperbolic-calculator.cpp
index dc0cd18..4b8cce7 100644
--- a/tests/test-hyperbolic-calculator.cpp
+++ b/tests/test-hyperbolic-calculator.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -57,8 +57,6 @@
   void setUpTopology(std::vector<double> anglesA, std::vector<double> anglesB,
                      std::vector<double> anglesC)
   {
-    INIT_LOGGERS("/tmp", "TRACE");
-
     Adjacent a(ROUTER_A_NAME, ndn::FaceUri(ROUTER_A_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
     Adjacent b(ROUTER_B_NAME, ndn::FaceUri(ROUTER_B_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
     Adjacent c(ROUTER_C_NAME, ndn::FaceUri(ROUTER_C_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
diff --git a/tests/test-link-state-calculator.cpp b/tests/test-link-state-calculator.cpp
index 31c9abf..c6fafd0 100644
--- a/tests/test-link-state-calculator.cpp
+++ b/tests/test-link-state-calculator.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -52,8 +52,6 @@
   // Triangle topology with routers A, B, C connected
   void setUpTopology()
   {
-    INIT_LOGGERS("/tmp", "TRACE");
-
     ConfParameter& conf = nlsr.getConfParameter();
     conf.setNetwork("/ndn");
     conf.setSiteName("/router");
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 0142579..197d5cd 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -57,8 +57,6 @@
 
     advanceClocks(ndn::time::milliseconds(1), 10);
     face.sentInterests.clear();
-
-    INIT_LOGGERS("/tmp", "DEBUG");
   }
 
   void
diff --git a/tests/test-name-prefix-table.cpp b/tests/test-name-prefix-table.cpp
index ceeb828..776b447 100644
--- a/tests/test-name-prefix-table.cpp
+++ b/tests/test-name-prefix-table.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -37,7 +37,6 @@
     , lsdb(nlsr.getLsdb())
     , npt(nlsr.getNamePrefixTable())
   {
-    INIT_LOGGERS("/tmp", "DEBUG");
   }
 
 public:
diff --git a/tests/test-sync-logic-handler.cpp b/tests/test-sync-logic-handler.cpp
index f696d42..b233b22 100644
--- a/tests/test-sync-logic-handler.cpp
+++ b/tests/test-sync-logic-handler.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -24,7 +24,6 @@
 #include "common.hpp"
 #include "nlsr.hpp"
 #include "lsa.hpp"
-#include "logger.hpp"
 
 #include <ndn-cxx/util/dummy-client-face.hpp>
 
@@ -59,8 +58,6 @@
     conf.buildRouterPrefix();
 
     addIdentity(conf.getRouterPrefix());
-
-    INIT_LOGGERS("/tmp", "TRACE");
   }
 
   void