Replace logging with one provided by ndn-cxx

Change-Id: I737d517c6a042120f8d81ea9b77c209444dc2b89
diff --git a/.travis.yml b/.travis.yml
index 508b081..f223e8c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,6 +3,8 @@
 env:
   global:
     - JOB_NAME=limited-build
+    - NDN_LOG=*=DEBUG
+    - BOOST_TEST_COLOR_OUTPUT=true
 matrix:
   include:
     - os: linux
diff --git a/README.md b/README.md
index 31c4a67..5628e70 100644
--- a/README.md
+++ b/README.md
@@ -14,8 +14,8 @@
 complete and up-to-date knowledge of the dataset changes, applications can decide whether
 or when to fetch which pieces of the data.
 
-ChronoSync uses [ndn-cxx](https://github.com/named-data/ndn-cxx) library as NDN
-  development library.
+ChronoSync uses [ndn-cxx](https://github.com/named-data/ndn-cxx) library as NDN development
+library.
 
 ChronoSync is an open source project licensed under GPL 3.0 (see `COPYING.md` for more
 detail).  We highly welcome all contributions to the ChronoSync code base, provided that
diff --git a/log4cxx.properties b/log4cxx.properties
deleted file mode 100644
index 0659753..0000000
--- a/log4cxx.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-# Set root logger level to DEBUG and its only appender to A1.
-log4j.rootLogger=ERROR, A1
-
-# A1 is set to be a ConsoleAppender.
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-
-# A1 uses PatternLayout.
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.target=System.err
-#log4j.appender.A1.layout.ConversionPattern=%d{dd-MMM HH:MM:SS,SSS} %p %c %m%n
-#log4j.appender.A1.layout.ConversionPattern=%d{hh:mm:ss,SSS} %-14t %-14c  %m%n
-log4j.appender.A1.layout.ConversionPattern=%d{ss,SSS}  %-12c  %m%n
-
-log4j.logger.SyncLogic = TRACE
-log4j.logger.SyncSocket = TRACE
-log4j.logger.SyncValidator = DEBUG
-#log4j.logger.SyncInterestTable = TRACE
-#log4j.logger.AppDataFetch = TRACE
-log4j.logger.Test = TRACE
-#log4j.logger.bgpparser=TRACE
-#log4j.logger.bgpparser.AttributeType=ERROR
-#log4j.logger.bgpparser.MRTCommonHeader=ERROR
-
diff --git a/src/logger.hpp b/src/logger.hpp
index 7e46ea5..78e3040 100644
--- a/src/logger.hpp
+++ b/src/logger.hpp
@@ -24,53 +24,17 @@
 #ifndef CHRONOSYNC_LOGGER_HPP
 #define CHRONOSYNC_LOGGER_HPP
 
-#ifdef HAVE_LOG4CXX
+#include <ndn-cxx/util/logger.hpp>
 
-#include <log4cxx/logger.h>
+#define INIT_LOGGER(name) NDN_LOG_INIT(sync.name)
 
-#define INIT_LOGGER(name) \
-  static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger(name)
+#define _LOG_ERROR(x) NDN_LOG_ERROR(x)
+#define _LOG_WARN(x)  NDN_LOG_WARN(x)
+#define _LOG_INFO(x)  NDN_LOG_INFO(x)
+#define _LOG_DEBUG(x) NDN_LOG_DEBUG(x)
+#define _LOG_TRACE(x) NDN_LOG_TRACE(x)
 
-#define _LOG_DEBUG(x) \
-  LOG4CXX_DEBUG(staticModuleLogger, x)
-
-#define _LOG_TRACE(x) \
-  LOG4CXX_TRACE(staticModuleLogger, x)
-
-#define _LOG_FUNCTION(x) \
-  LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "(" << x << ")")
-
-#define _LOG_FUNCTION_NOARGS \
-  LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "()")
-
-#define _LOG_ERROR(x) \
-  LOG4CXX_ERROR(staticModuleLogger, x)
-
-#else // HAVE_LOG4CXX
-
-#define INIT_LOGGER(name)    struct chronosync__allow_trailing_semicolon
-#define _LOG_FUNCTION(x)     struct chronosync__allow_trailing_semicolon
-#define _LOG_FUNCTION_NOARGS struct chronosync__allow_trailing_semicolon
-#define _LOG_TRACE(x)        struct chronosync__allow_trailing_semicolon
-#define INIT_LOGGERS(x)      struct chronosync__allow_trailing_semicolon
-#define _LOG_ERROR(x)        struct chronosync__allow_trailing_semicolon
-
-#ifdef _DEBUG
-
-#include <thread>
-#include <iostream>
-#include <ndn-cxx/util/time.hpp>
-
-#define _LOG_DEBUG(x) \
-  std::clog << ndn::time::system_clock::now() << " " << std::this_thread::get_id() << \
-               " " << x << std::endl
-
-#else // _DEBUG
-
-#define _LOG_DEBUG(x) struct chronosync__allow_trailing_semicolon
-
-#endif // _DEBUG
-
-#endif // HAVE_LOG4CXX
+#define _LOG_FUNCTION(x)     NDN_LOG_TRACE(__FUNCTION__ << "(" << x << ")")
+#define _LOG_FUNCTION_NOARGS NDN_LOG_TRACE(__FUNCTION__ << "()")
 
 #endif // CHRONOSYNC_LOGGER_HPP
diff --git a/src/logic.cpp b/src/logic.cpp
index 25f2abb..e67aef4 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -25,7 +25,7 @@
 #include "logic.hpp"
 #include "logger.hpp"
 
-INIT_LOGGER("Logic");
+INIT_LOGGER(Logic);
 
 #ifdef _DEBUG
 #define _LOG_DEBUG_ID(v) _LOG_DEBUG("Instance" << m_instanceId << ": " << v)
diff --git a/src/socket.cpp b/src/socket.cpp
index 71ff606..4d46d7f 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2012-2016 University of California, Los Angeles
+ * Copyright (c) 2012-2017 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -25,7 +25,7 @@
 #include "socket.hpp"
 #include "logger.hpp"
 
-INIT_LOGGER("Socket");
+INIT_LOGGER(Socket);
 
 
 namespace chronosync {
diff --git a/tests/wscript b/tests/wscript
index b157a32..bacd16b 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -17,7 +17,7 @@
         target="../unit-tests",
         source=bld.path.ant_glob(['unit-tests/**/*.cpp']),
         features=['cxx', 'cxxprogram'],
-        use='ChronoSync tests-main LOG4CXX',
+        use='ChronoSync tests-main',
         includes=['.'],
         install_path=None,
         )
diff --git a/wscript b/wscript
index 8a484b0..e3e3b1e 100644
--- a/wscript
+++ b/wscript
@@ -16,8 +16,6 @@
 
     syncopt.add_option('--debug', action='store_true', default=False, dest='debug',
                        help='''debugging mode''')
-    syncopt.add_option('--with-log4cxx', action='store_true', default=False, dest='log4cxx',
-                       help='''Compile with log4cxx''')
     syncopt.add_option('--with-tests', action='store_true', default=False, dest='_tests',
                        help='''build unit tests''')
 
@@ -29,17 +27,13 @@
     conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
                    uselib_store='NDN_CXX', mandatory=True)
 
-    boost_libs = 'system iostreams'
+    boost_libs = 'system iostreams thread log log_setup'
     if conf.options._tests:
         conf.env['CHRONOSYNC_HAVE_TESTS'] = 1
         conf.define('CHRONOSYNC_HAVE_TESTS', 1);
         boost_libs += ' unit_test_framework'
 
-    conf.check_boost(lib=boost_libs)
-
-    if conf.options.log4cxx:
-        conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX',
-                       mandatory=True)
+    conf.check_boost(lib=boost_libs, mt=True)
 
     # If there happens to be a static library, waf will put the corresponding -L flags
     # before dynamic library flags.  This can result in compilation failure when the
@@ -55,7 +49,7 @@
         cnum = VERSION,
         features=['cxx', 'cxxshlib'],
         source =  bld.path.ant_glob(['src/**/*.cpp', 'src/**/*.proto']),
-        use = 'BOOST NDN_CXX LOG4CXX',
+        use = 'BOOST NDN_CXX',
         includes = ['src', '.'],
         export_includes=['src', '.'],
         )