Move config.hpp and a few more private headers to a 'detail' subdir

Also upgrade waf to version 2.0.21

Change-Id: Id290b8336c607fb3939f2ab96dd066dae9810c1e
diff --git a/src/bzip2-helper.cpp b/src/detail/bzip2-helper.cpp
similarity index 94%
rename from src/bzip2-helper.cpp
rename to src/detail/bzip2-helper.cpp
index 527c4f4..0784b7f 100644
--- a/src/bzip2-helper.cpp
+++ b/src/detail/bzip2-helper.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2012-2018 University of California, Los Angeles
+ * Copyright (c) 2012-2021 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -17,7 +17,7 @@
  * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "bzip2-helper.hpp"
+#include "detail/bzip2-helper.hpp"
 
 #include <boost/iostreams/filtering_stream.hpp>
 #include <boost/iostreams/detail/iostream.hpp>
diff --git a/src/bzip2-helper.hpp b/src/detail/bzip2-helper.hpp
similarity index 86%
rename from src/bzip2-helper.hpp
rename to src/detail/bzip2-helper.hpp
index 60485c4..47ff5ac 100644
--- a/src/bzip2-helper.hpp
+++ b/src/detail/bzip2-helper.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2012-2018 University of California, Los Angeles
+ * Copyright (c) 2012-2021 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -17,8 +17,8 @@
  * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef CHRONOSYNC_BZIP2_HELPER_HPP
-#define CHRONOSYNC_BZIP2_HELPER_HPP
+#ifndef CHRONOSYNC_DETAIL_BZIP2_HELPER_HPP
+#define CHRONOSYNC_DETAIL_BZIP2_HELPER_HPP
 
 #include <ndn-cxx/encoding/buffer.hpp>
 
@@ -40,4 +40,4 @@
 } // namespace bzip2
 } // namespace chronosync
 
-#endif // CHRONOSYNC_BZIP2_HELPER_HPP
+#endif // CHRONOSYNC_DETAIL_BZIP2_HELPER_HPP
diff --git a/src/detail/common.hpp b/src/detail/common.hpp
new file mode 100644
index 0000000..4e9e4cd
--- /dev/null
+++ b/src/detail/common.hpp
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2021 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
+ * @author Yingdi Yu <yingdi@cs.ucla.edu>
+ */
+
+#ifndef CHRONOSYNC_DETAIL_COMMON_HPP
+#define CHRONOSYNC_DETAIL_COMMON_HPP
+
+#include "detail/config.hpp"
+
+#ifdef CHRONOSYNC_WITH_TESTS
+#define CHRONOSYNC_VIRTUAL_WITH_TESTS virtual
+#define CHRONOSYNC_PUBLIC_WITH_TESTS_ELSE_PROTECTED public
+#define CHRONOSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE public
+#define CHRONOSYNC_PROTECTED_WITH_TESTS_ELSE_PRIVATE protected
+#else
+#define CHRONOSYNC_VIRTUAL_WITH_TESTS
+#define CHRONOSYNC_PUBLIC_WITH_TESTS_ELSE_PROTECTED protected
+#define CHRONOSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE private
+#define CHRONOSYNC_PROTECTED_WITH_TESTS_ELSE_PRIVATE private
+#endif
+
+#include <cstddef>
+#include <list>
+#include <queue>
+#include <set>
+#include <vector>
+#include <tuple>
+
+#include <ndn-cxx/data.hpp>
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/interest.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/security/signing-helpers.hpp>
+#include <ndn-cxx/security/validator.hpp>
+#include <ndn-cxx/security/validator-config.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
+#include <ndn-cxx/util/time.hpp>
+
+#include <boost/algorithm/string.hpp>
+#include <boost/asio.hpp>
+#include <boost/assert.hpp>
+#include <boost/core/noncopyable.hpp>
+#include <boost/lexical_cast.hpp>
+
+namespace chronosync {
+
+using std::size_t;
+
+using boost::noncopyable;
+
+using std::bind;
+using std::cref;
+using std::function;
+using std::make_shared;
+using std::make_tuple;
+using std::ref;
+using std::shared_ptr;
+
+using ndn::Block;
+using ndn::ConstBufferPtr;
+using ndn::Data;
+using ndn::Interest;
+using ndn::Name;
+using ndn::security::ValidationError;
+using ndn::security::Validator;
+
+namespace tlv {
+using namespace ndn::tlv;
+} // namespace tlv
+
+namespace name = ndn::name;
+namespace time = ndn::time;
+namespace security = ndn::security;
+namespace encoding = ndn::encoding;
+
+} // namespace chronosync
+
+#endif // CHRONOSYNC_DETAIL_COMMON_HPP
diff --git a/src/mi-tag.hpp b/src/detail/mi-tag.hpp
similarity index 87%
rename from src/mi-tag.hpp
rename to src/detail/mi-tag.hpp
index 1abafc4..a64195e 100644
--- a/src/mi-tag.hpp
+++ b/src/detail/mi-tag.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2012-2014 University of California, Los Angeles
+ * Copyright (c) 2012-2021 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -22,8 +22,8 @@
  * @author Yingdi Yu <yingdi@cs.ucla.edu>
  */
 
-#ifndef CHRONOSYNC_MI_TAG_HPP
-#define CHRONOSYNC_MI_TAG_HPP
+#ifndef CHRONOSYNC_DETAIL_MI_TAG_HPP
+#define CHRONOSYNC_DETAIL_MI_TAG_HPP
 
 namespace chronosync {
 
@@ -40,11 +40,6 @@
 {
 };
 
-struct timed
-{
-};
-
-
 } // namespace chronosync
 
-#endif // CHRONOSYNC_MI_TAG_HPP
+#endif // CHRONOSYNC_DETAIL_MI_TAG_HPP
diff --git a/src/diff-state-container.hpp b/src/diff-state-container.hpp
index dbd4a11..615d639 100644
--- a/src/diff-state-container.hpp
+++ b/src/diff-state-container.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2012-2017 University of California, Los Angeles
+ * Copyright (c) 2012-2021 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -25,15 +25,14 @@
 #ifndef CHRONOSYNC_DIFF_STATE_CONTAINER_HPP
 #define CHRONOSYNC_DIFF_STATE_CONTAINER_HPP
 
-#include "mi-tag.hpp"
+#include "detail/mi-tag.hpp"
 #include "diff-state.hpp"
 
 #include <boost/multi_index_container.hpp>
-#include <boost/multi_index/tag.hpp>
 #include <boost/multi_index/hashed_index.hpp>
 #include <boost/multi_index/sequenced_index.hpp>
-#include <boost/multi_index/member.hpp>
 #include <boost/multi_index/mem_fun.hpp>
+#include <boost/multi_index/tag.hpp>
 
 namespace chronosync {
 
@@ -72,9 +71,8 @@
       DigestPtrHash,
       DigestPtrEqual
       >,
-
     // sequenced index to access older/newer element (like in list)
-    mi::sequenced<mi::tag<sequenced> >
+    mi::sequenced<mi::tag<sequenced>>
     >
   >
 {
diff --git a/src/interest-container.hpp b/src/interest-container.hpp
index 56c08ce..9ad3816 100644
--- a/src/interest-container.hpp
+++ b/src/interest-container.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2012-2019 University of California, Los Angeles
+ * Copyright (c) 2012-2021 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -25,15 +25,12 @@
 #ifndef CHRONOSYNC_INTEREST_CONTAINER_HPP
 #define CHRONOSYNC_INTEREST_CONTAINER_HPP
 
-#include "common.hpp"
-#include "mi-tag.hpp"
 #include "diff-state-container.hpp"
 
 #include <boost/multi_index_container.hpp>
-#include <boost/multi_index/tag.hpp>
 #include <boost/multi_index/hashed_index.hpp>
-#include <boost/multi_index/ordered_index.hpp>
 #include <boost/multi_index/member.hpp>
+#include <boost/multi_index/tag.hpp>
 
 namespace chronosync {
 
diff --git a/src/leaf-container.hpp b/src/leaf-container.hpp
index 95ddc75..4e7a805 100644
--- a/src/leaf-container.hpp
+++ b/src/leaf-container.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2012-2017 University of California, Los Angeles
+ * Copyright (c) 2012-2021 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -25,13 +25,14 @@
 #ifndef CHRONOSYNC_LEAF_CONTAINER_HPP
 #define CHRONOSYNC_LEAF_CONTAINER_HPP
 
-#include "mi-tag.hpp"
+#include "detail/mi-tag.hpp"
 #include "leaf.hpp"
 
 #include <boost/multi_index_container.hpp>
-#include <boost/multi_index/ordered_index.hpp>
 #include <boost/multi_index/hashed_index.hpp>
+#include <boost/multi_index/ordered_index.hpp>
 #include <boost/multi_index/mem_fun.hpp>
+#include <boost/multi_index/tag.hpp>
 
 #include <ndn-cxx/util/sha256.hpp>
 
diff --git a/src/leaf.hpp b/src/leaf.hpp
index 63284b8..952b063 100644
--- a/src/leaf.hpp
+++ b/src/leaf.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2012-2017 University of California, Los Angeles
+ * Copyright (c) 2012-2021 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -25,7 +25,7 @@
 #ifndef CHRONOSYNC_LEAF_HPP
 #define CHRONOSYNC_LEAF_HPP
 
-#include "common.hpp"
+#include "detail/common.hpp"
 
 #include <ndn-cxx/util/sha256.hpp>
 
diff --git a/src/logger.hpp b/src/logger.hpp
deleted file mode 100644
index 78e3040..0000000
--- a/src/logger.hpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012-2017 University of California, Los Angeles
- *
- * This file is part of ChronoSync, synchronization library for distributed realtime
- * applications for NDN.
- *
- * ChronoSync is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation, either
- * version 3 of the License, or (at your option) any later version.
- *
- * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- *
- * @author Zhenkai Zhu <http://irl.cs.ucla.edu/~zhenkai/>
- * @author Chaoyi Bian <bcy@pku.edu.cn>
- * @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
- */
-
-#ifndef CHRONOSYNC_LOGGER_HPP
-#define CHRONOSYNC_LOGGER_HPP
-
-#include <ndn-cxx/util/logger.hpp>
-
-#define INIT_LOGGER(name) NDN_LOG_INIT(sync.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_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 6d52def..db6bc02 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2012-2020 University of California, Los Angeles
+ * Copyright (c) 2012-2021 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -24,16 +24,16 @@
  */
 
 #include "logic.hpp"
-#include "logger.hpp"
-#include "bzip2-helper.hpp"
+#include "detail/bzip2-helper.hpp"
 
 #include <ndn-cxx/util/backports.hpp>
 #include <ndn-cxx/util/exception.hpp>
+#include <ndn-cxx/util/logger.hpp>
 #include <ndn-cxx/util/string-helper.hpp>
 
-INIT_LOGGER(Logic);
+NDN_LOG_INIT(sync.Logic);
 
-#define _LOG_DEBUG_ID(v) _LOG_DEBUG("Instance" << m_instanceId << ": " << v)
+#define CHRONO_LOG_DBG(v) NDN_LOG_DEBUG("Instance" << m_instanceId << ": " << v)
 
 namespace chronosync {
 
@@ -69,18 +69,18 @@
  * The returned value can be customized using the environment variable `CHRONOSYNC_MAX_PACKET_SIZE`,
  * but the returned value will be at least 500 and no more than `ndn::MAX_NDN_PACKET_SIZE`.
  */
-#ifndef CHRONOSYNC_HAVE_TESTS
+#ifndef CHRONOSYNC_WITH_TESTS
 static
-#endif // CHRONOSYNC_HAVE_TESTS
+#endif // CHRONOSYNC_WITH_TESTS
 size_t
 getMaxPacketLimit()
 {
   static size_t limit = 0;
-#ifndef CHRONOSYNC_HAVE_TESTS
+#ifndef CHRONOSYNC_WITH_TESTS
   if (limit != 0) {
     return limit;
   }
-#endif // CHRONOSYNC_HAVE_TESTS
+#endif // CHRONOSYNC_WITH_TESTS
 
   if (getenv("CHRONOSYNC_MAX_PACKET_SIZE") != nullptr) {
     try {
@@ -132,25 +132,25 @@
   , m_validator(validator)
   , m_instanceId(s_instanceCounter++)
 {
-  _LOG_DEBUG_ID(">> Logic::Logic");
+  CHRONO_LOG_DBG(">> Logic::Logic");
   addUserNode(m_defaultUserPrefix, defaultSigningId, session, false);
 
-  _LOG_DEBUG_ID("Listen to: " << m_syncPrefix);
+  CHRONO_LOG_DBG("Listen to: " << m_syncPrefix);
   m_syncRegisteredPrefix = m_face.setInterestFilter(
     ndn::InterestFilter(m_syncPrefix).allowLoopback(false),
     bind(&Logic::onSyncInterest, this, _1, _2),
     bind(&Logic::onSyncRegisterFailed, this, _1, _2));
 
   sendSyncInterest();
-  _LOG_DEBUG_ID("<< Logic::Logic");
+  CHRONO_LOG_DBG("<< Logic::Logic");
 }
 
 Logic::~Logic()
 {
-  _LOG_DEBUG_ID(">> Logic::~Logic");
+  CHRONO_LOG_DBG(">> Logic::~Logic");
   m_interestTable.clear();
   m_scheduler.cancelAllEvents();
-  _LOG_DEBUG_ID("<< Logic::~Logic");
+  CHRONO_LOG_DBG("<< Logic::~Logic");
 }
 
 void
@@ -262,20 +262,20 @@
   auto it = m_nodeList.find(prefix);
   if (it != m_nodeList.end()) {
     NodeInfo& node = it->second;
-    _LOG_DEBUG_ID(">> Logic::updateSeqNo");
-    _LOG_DEBUG_ID("seqNo: " << seqNo << " m_seqNo: " << node.seqNo);
+    CHRONO_LOG_DBG(">> Logic::updateSeqNo");
+    CHRONO_LOG_DBG("seqNo: " << seqNo << " m_seqNo: " << node.seqNo);
     if (seqNo < node.seqNo || seqNo == 0)
       return;
 
     node.seqNo = seqNo;
-    _LOG_DEBUG_ID("updateSeqNo: m_seqNo " << node.seqNo);
+    CHRONO_LOG_DBG("updateSeqNo: m_seqNo " << node.seqNo);
 
     if (!m_isInReset) {
-      _LOG_DEBUG_ID("updateSeqNo: not in Reset ");
+      CHRONO_LOG_DBG("updateSeqNo: not in Reset");
       ConstBufferPtr previousRoot = m_state.getRootDigest();
       {
         std::string hash = ndn::toHex(previousRoot->data(), previousRoot->size(), false);
-        _LOG_DEBUG_ID("Hash: " << hash);
+        CHRONO_LOG_DBG("Hash: " << hash);
       }
 
       bool isInserted = false;
@@ -283,8 +283,8 @@
       SeqNo oldSeq;
       std::tie(isInserted, isUpdated, oldSeq) = m_state.update(node.sessionName, node.seqNo);
 
-      _LOG_DEBUG_ID("Insert: " << std::boolalpha << isInserted);
-      _LOG_DEBUG_ID("Updated: " << std::boolalpha << isUpdated);
+      CHRONO_LOG_DBG("Insert: " << std::boolalpha << isInserted);
+      CHRONO_LOG_DBG("Updated: " << std::boolalpha << isUpdated);
       if (isInserted || isUpdated) {
         DiffStatePtr commit = make_shared<DiffState>();
         commit->update(node.sessionName, node.seqNo);
@@ -322,12 +322,12 @@
 }
 
 void
-Logic::onSyncInterest(const Name& prefix, const Interest& interest)
+Logic::onSyncInterest(const Name&, const Interest& interest)
 {
-  _LOG_DEBUG_ID(">> Logic::onSyncInterest");
+  CHRONO_LOG_DBG(">> Logic::onSyncInterest");
   Name name = interest.getName();
 
-  _LOG_DEBUG_ID("InterestName: " << name);
+  CHRONO_LOG_DBG("InterestName: " << name);
 
   if (name.size() >= 1 && RESET_COMPONENT == name.get(-1)) {
     processResetInterest(interest);
@@ -339,20 +339,19 @@
     processSyncInterest(interest);
   }
 
-  _LOG_DEBUG_ID("<< Logic::onSyncInterest");
+  CHRONO_LOG_DBG("<< Logic::onSyncInterest");
 }
 
 void
 Logic::onSyncRegisterFailed(const Name& prefix, const std::string& msg)
 {
-  //Sync prefix registration failed
-  _LOG_DEBUG_ID(">> Logic::onSyncRegisterFailed");
+  CHRONO_LOG_DBG(">> Logic::onSyncRegisterFailed");
 }
 
 void
-Logic::onSyncData(const Interest& interest, const Data& data)
+Logic::onSyncData(const Interest&, const Data& data)
 {
-  _LOG_DEBUG_ID(">> Logic::onSyncData");
+  CHRONO_LOG_DBG(">> Logic::onSyncData");
   if (m_validator != nullptr)
     m_validator->validate(data,
                           bind(&Logic::onSyncDataValidated, this, _1),
@@ -360,38 +359,38 @@
   else
      onSyncDataValidated(data);
 
-  _LOG_DEBUG_ID("<< Logic::onSyncData");
+  CHRONO_LOG_DBG("<< Logic::onSyncData");
 }
 
 void
-Logic::onResetData(const Interest& interest, const Data& data)
+Logic::onResetData(const Interest&, const Data&)
 {
   // This should not happened, drop the received data.
 }
 
 void
-Logic::onSyncNack(const Interest& interest, const ndn::lp::Nack& nack)
+Logic::onSyncNack(const Interest&, const ndn::lp::Nack& nack)
 {
-  _LOG_DEBUG_ID(">> Logic::onSyncNack");
+  CHRONO_LOG_DBG(">> Logic::onSyncNack");
   if (nack.getReason() == ndn::lp::NackReason::NO_ROUTE) {
     auto after = ndn::time::milliseconds(m_reexpressionJitter(m_rng));
-    _LOG_DEBUG_ID("Schedule sync interest after: " << after);
+    CHRONO_LOG_DBG("Schedule sync interest after: " << after);
     m_scheduler.schedule(after, [this] { sendSyncInterest(); });
   }
-  _LOG_DEBUG_ID("<< Logic::onSyncNack");
+  CHRONO_LOG_DBG("<< Logic::onSyncNack");
 }
 
 void
 Logic::onSyncTimeout(const Interest& interest)
 {
   // It is OK. Others will handle the time out situation.
-  _LOG_DEBUG_ID(">> Logic::onSyncTimeout");
-  _LOG_DEBUG_ID("Interest: " << interest.getName());
-  _LOG_DEBUG_ID("<< Logic::onSyncTimeout");
+  CHRONO_LOG_DBG(">> Logic::onSyncTimeout");
+  CHRONO_LOG_DBG("Interest: " << interest.getName());
+  CHRONO_LOG_DBG("<< Logic::onSyncTimeout");
 }
 
 void
-Logic::onSyncDataValidationFailed(const Data& data)
+Logic::onSyncDataValidationFailed(const Data&)
 {
   // SyncReply cannot be validated.
 }
@@ -408,14 +407,14 @@
     processSyncData(name, digest, Block(std::move(contentBuffer)));
   }
   catch (const std::ios_base::failure& error) {
-    _LOG_WARN("Error decompressing content of " << data.getName() << " (" << error.what() << ")");
+    NDN_LOG_WARN("Error decompressing content of " << data.getName() << " (" << error.what() << ")");
   }
 }
 
 void
 Logic::processSyncInterest(const Interest& interest, bool isTimedProcessing/*=false*/)
 {
-  _LOG_DEBUG_ID(">> Logic::processSyncInterest");
+  CHRONO_LOG_DBG(">> Logic::processSyncInterest");
 
   Name name = interest.getName();
   ConstBufferPtr digest = make_shared<ndn::Buffer>(name.get(-1).value(), name.get(-1).value_size());
@@ -425,23 +424,23 @@
   // If the digest of the incoming interest is the same as root digest
   // Put the interest into InterestTable
   if (*rootDigest == *digest) {
-    _LOG_DEBUG_ID("Oh, we are in the same state");
+    CHRONO_LOG_DBG("Oh, we are in the same state");
     m_interestTable.insert(interest, digest, false);
 
     if (!m_isInReset)
       return;
 
     if (!isTimedProcessing) {
-      _LOG_DEBUG_ID("Non timed processing in reset");
+      CHRONO_LOG_DBG("Non timed processing in reset");
       // Still in reset, our own seq has not been put into state yet
       // Do not hurry, some others may be also resetting and may send their reply
       time::milliseconds after(m_rangeUniformRandom(m_rng));
-      _LOG_DEBUG_ID("After: " << after);
+      CHRONO_LOG_DBG("After: " << after);
       m_delayedInterestProcessingId = m_scheduler.schedule(after,
                                                            [=] { processSyncInterest(interest, true); });
     }
     else {
-      _LOG_DEBUG_ID("Timed processing in reset");
+      CHRONO_LOG_DBG("Timed processing in reset");
       // Now we can get out of reset state by putting our own stuff into m_state.
       cancelReset();
     }
@@ -451,7 +450,7 @@
 
   // If the digest of incoming interest is an "empty" digest
   if (*digest == *EMPTY_DIGEST) {
-    _LOG_DEBUG_ID("Poor guy, he knows nothing");
+    CHRONO_LOG_DBG("Poor guy, he knows nothing");
     sendSyncData(m_defaultUserPrefix, name, m_state);
     return;
   }
@@ -459,13 +458,13 @@
   auto stateIter = m_log.find(digest);
   // If the digest of incoming interest can be found from the log
   if (stateIter != m_log.end()) {
-    _LOG_DEBUG_ID("It is ok, you are so close");
+    CHRONO_LOG_DBG("It is ok, you are so close");
     sendSyncData(m_defaultUserPrefix, name, *(*stateIter)->diff());
     return;
   }
 
   if (!isTimedProcessing) {
-    _LOG_DEBUG_ID("Let's wait, just wait for a while");
+    CHRONO_LOG_DBG("Let's wait, just wait for a while");
     // Do not hurry, some incoming SyncReplies may help us to recognize the digest
     m_interestTable.insert(interest, digest, true);
 
@@ -475,25 +474,25 @@
   }
   else {
     // OK, nobody is helping us, just tell the truth.
-    _LOG_DEBUG_ID("OK, nobody is helping us, let us try to recover");
+    CHRONO_LOG_DBG("OK, nobody is helping us, let us try to recover");
     m_interestTable.erase(digest);
     sendRecoveryInterest(digest);
   }
 
-  _LOG_DEBUG_ID("<< Logic::processSyncInterest");
+  CHRONO_LOG_DBG("<< Logic::processSyncInterest");
 }
 
 void
 Logic::processResetInterest(const Interest&)
 {
-  _LOG_DEBUG_ID(">> Logic::processResetInterest");
+  CHRONO_LOG_DBG(">> Logic::processResetInterest");
   reset(true);
 }
 
 void
 Logic::processSyncData(const Name&, ConstBufferPtr digest, const Block& syncReply)
 {
-  _LOG_DEBUG_ID(">> Logic::processSyncData");
+  CHRONO_LOG_DBG(">> Logic::processSyncData");
   DiffStatePtr commit = make_shared<DiffState>();
   ConstBufferPtr previousRoot = m_state.getRootDigest();
 
@@ -528,12 +527,11 @@
       insertToDiffLog(commit, previousRoot);
     }
     else {
-      _LOG_DEBUG_ID("What? nothing new");
+      CHRONO_LOG_DBG("What? nothing new");
     }
   }
   catch (const State::Error&) {
-    _LOG_DEBUG_ID("Something really fishy happened during state decoding");
-    // Something really fishy happened during state decoding;
+    CHRONO_LOG_DBG("Something really fishy happened during state decoding");
     commit.reset();
     return;
   }
@@ -541,7 +539,7 @@
   if (static_cast<bool>(commit) && !commit->getLeaves().empty()) {
     // state changed and it is safe to express a new interest
     auto after = time::milliseconds(m_reexpressionJitter(m_rng));
-    _LOG_DEBUG_ID("Reschedule sync interest after: " << after);
+    CHRONO_LOG_DBG("Reschedule sync interest after: " << after);
     m_reexpressingInterestId = m_scheduler.schedule(after, [this] { sendSyncInterest(); });
   }
 }
@@ -549,9 +547,9 @@
 void
 Logic::satisfyPendingSyncInterests(const Name& updatedPrefix, ConstDiffStatePtr commit)
 {
-  _LOG_DEBUG_ID(">> Logic::satisfyPendingSyncInterests");
+  CHRONO_LOG_DBG(">> Logic::satisfyPendingSyncInterests");
   try {
-    _LOG_DEBUG_ID("InterestTable size: " << m_interestTable.size());
+    CHRONO_LOG_DBG("InterestTable size: " << m_interestTable.size());
     auto it = m_interestTable.begin();
     while (it != m_interestTable.end()) {
       ConstUnsatisfiedInterestPtr request = *it;
@@ -566,13 +564,13 @@
   catch (const InterestTable::Error&) {
     // ok. not really an error
   }
-  _LOG_DEBUG_ID("<< Logic::satisfyPendingSyncInterests");
+  CHRONO_LOG_DBG("<< Logic::satisfyPendingSyncInterests");
 }
 
 void
 Logic::insertToDiffLog(DiffStatePtr commit, ConstBufferPtr previousRoot)
 {
-  _LOG_DEBUG_ID(">> Logic::insertToDiffLog");
+  CHRONO_LOG_DBG(">> Logic::insertToDiffLog");
   // Connect to the history
   if (!m_log.empty())
     (*m_log.find(previousRoot))->setNext(commit);
@@ -580,17 +578,17 @@
   // Insert the commit
   m_log.erase(commit->getRootDigest());
   m_log.insert(commit);
-  _LOG_DEBUG_ID("<< Logic::insertToDiffLog");
+  CHRONO_LOG_DBG("<< Logic::insertToDiffLog");
 }
 
 void
 Logic::sendResetInterest()
 {
-  _LOG_DEBUG_ID(">> Logic::sendResetInterest");
+  CHRONO_LOG_DBG(">> Logic::sendResetInterest");
 
   if (m_needPeriodReset) {
-    _LOG_DEBUG_ID("Need Period Reset");
-    _LOG_DEBUG_ID("ResetTimer: " << m_resetTimer);
+    CHRONO_LOG_DBG("Need Period Reset");
+    CHRONO_LOG_DBG("ResetTimer: " << m_resetTimer);
 
     m_resetInterestId = m_scheduler.schedule(m_resetTimer + time::milliseconds(m_reexpressionJitter(m_rng)),
                                              [this] { sendResetInterest(); });
@@ -607,13 +605,13 @@
     bind(&Logic::onResetData, this, _1, _2),
     bind(&Logic::onSyncTimeout, this, _1), // Nack
     bind(&Logic::onSyncTimeout, this, _1));
-  _LOG_DEBUG_ID("<< Logic::sendResetInterest");
+  CHRONO_LOG_DBG("<< Logic::sendResetInterest");
 }
 
 void
 Logic::sendSyncInterest()
 {
-  _LOG_DEBUG_ID(">> Logic::sendSyncInterest");
+  CHRONO_LOG_DBG(">> Logic::sendSyncInterest");
 
   Name interestName;
   interestName.append(m_syncPrefix)
@@ -639,8 +637,8 @@
                                                  bind(&Logic::onSyncNack, this, _1, _2),
                                                  bind(&Logic::onSyncTimeout, this, _1));
 
-  _LOG_DEBUG_ID("Send interest: " << interest.getName());
-  _LOG_DEBUG_ID("<< Logic::sendSyncInterest");
+  CHRONO_LOG_DBG("Send interest: " << interest.getName());
+  CHRONO_LOG_DBG("<< Logic::sendSyncInterest");
 }
 
 void
@@ -688,7 +686,8 @@
   while (syncReply.wireEncode().size() > getMaxPacketLimit() - NDNLP_EXPECTED_OVERHEAD) {
     if (nExcludedStates == 1) {
       // To show this debug message only once
-      _LOG_DEBUG("Sync reply size exceeded maximum packet limit (" << (getMaxPacketLimit() - NDNLP_EXPECTED_OVERHEAD) << ")");
+      NDN_LOG_DEBUG("Sync reply size exceeded maximum packet limit ("
+                    << (getMaxPacketLimit() - NDNLP_EXPECTED_OVERHEAD) << ")");
     }
     State partialState;
     trimState(partialState, state, nExcludedStates);
@@ -704,7 +703,7 @@
 void
 Logic::sendSyncData(const Name& nodePrefix, const Name& name, const State& state)
 {
-  _LOG_DEBUG_ID(">> Logic::sendSyncData");
+  CHRONO_LOG_DBG(">> Logic::sendSyncData");
   if (m_nodeList.find(nodePrefix) == m_nodeList.end())
     return;
 
@@ -717,17 +716,17 @@
 
     // re-schedule sending Sync interest
     time::milliseconds after(m_reexpressionJitter(m_rng));
-    _LOG_DEBUG_ID("Satisfy our own interest");
-    _LOG_DEBUG_ID("Reschedule sync interest after " << after);
+    CHRONO_LOG_DBG("Satisfy our own interest");
+    CHRONO_LOG_DBG("Reschedule sync interest after " << after);
     m_reexpressingInterestId = m_scheduler.schedule(after, [this] { sendSyncInterest(); });
   }
-  _LOG_DEBUG_ID("<< Logic::sendSyncData");
+  CHRONO_LOG_DBG("<< Logic::sendSyncData");
 }
 
 void
 Logic::cancelReset()
 {
-  _LOG_DEBUG_ID(">> Logic::cancelReset");
+  CHRONO_LOG_DBG(">> Logic::cancelReset");
   if (!m_isInReset)
     return;
 
@@ -735,20 +734,20 @@
   for (const auto& node : m_nodeList) {
     updateSeqNo(node.second.seqNo, node.first);
   }
-  _LOG_DEBUG_ID("<< Logic::cancelReset");
+  CHRONO_LOG_DBG("<< Logic::cancelReset");
 }
 
 void
 Logic::printDigest(ConstBufferPtr digest)
 {
   std::string hash = ndn::toHex(digest->data(), digest->size(), false);
-  _LOG_DEBUG_ID("Hash: " << hash);
+  CHRONO_LOG_DBG("Hash: " << hash);
 }
 
 void
 Logic::sendRecoveryInterest(ConstBufferPtr digest)
 {
-  _LOG_DEBUG_ID(">> Logic::sendRecoveryInterest");
+  CHRONO_LOG_DBG(">> Logic::sendRecoveryInterest");
 
   Name interestName;
   interestName.append(m_syncPrefix)
@@ -764,14 +763,14 @@
     bind(&Logic::onRecoveryData, this, _1, _2),
     bind(&Logic::onRecoveryTimeout, this, _1), // Nack
     bind(&Logic::onRecoveryTimeout, this, _1));
-  _LOG_DEBUG_ID("interest: " << interest.getName());
-  _LOG_DEBUG_ID("<< Logic::sendRecoveryInterest");
+  CHRONO_LOG_DBG("interest: " << interest.getName());
+  CHRONO_LOG_DBG("<< Logic::sendRecoveryInterest");
 }
 
 void
 Logic::processRecoveryInterest(const Interest& interest)
 {
-  _LOG_DEBUG_ID(">> Logic::processRecoveryInterest");
+  CHRONO_LOG_DBG(">> Logic::processRecoveryInterest");
 
   Name name = interest.getName();
   ConstBufferPtr digest = make_shared<ndn::Buffer>(name.get(-1).value(), name.get(-1).value_size());
@@ -779,30 +778,30 @@
 
   auto stateIter = m_log.find(digest);
   if (stateIter != m_log.end() || *digest == *EMPTY_DIGEST || *rootDigest == *digest) {
-    _LOG_DEBUG_ID("I can help you recover");
+    CHRONO_LOG_DBG("I can help you recover");
     sendSyncData(m_defaultUserPrefix, name, m_state);
     return;
   }
 
-  _LOG_DEBUG_ID("<< Logic::processRecoveryInterest");
+  CHRONO_LOG_DBG("<< Logic::processRecoveryInterest");
 }
 
 void
 Logic::onRecoveryData(const Interest& interest, const Data& data)
 {
-  _LOG_DEBUG_ID(">> Logic::onRecoveryData");
+  CHRONO_LOG_DBG(">> Logic::onRecoveryData");
   m_pendingRecoveryInterests.erase(interest.getName()[-1].toUri());
   onSyncDataValidated(data);
-  _LOG_DEBUG_ID("<< Logic::onRecoveryData");
+  CHRONO_LOG_DBG("<< Logic::onRecoveryData");
 }
 
 void
 Logic::onRecoveryTimeout(const Interest& interest)
 {
-  _LOG_DEBUG_ID(">> Logic::onRecoveryTimeout");
+  CHRONO_LOG_DBG(">> Logic::onRecoveryTimeout");
   m_pendingRecoveryInterests.erase(interest.getName()[-1].toUri());
-  _LOG_DEBUG_ID("Interest: " << interest.getName());
-  _LOG_DEBUG_ID("<< Logic::onRecoveryTimeout");
+  CHRONO_LOG_DBG("Interest: " << interest.getName());
+  CHRONO_LOG_DBG("<< Logic::onRecoveryTimeout");
 }
 
 } // namespace chronosync
diff --git a/src/logic.hpp b/src/logic.hpp
index e016a9e..25514ed 100644
--- a/src/logic.hpp
+++ b/src/logic.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2012-2020 University of California, Los Angeles
+ * Copyright (c) 2012-2021 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -81,14 +81,9 @@
   class Error : public std::runtime_error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
+    using std::runtime_error::runtime_error;
   };
 
-public:
   static const time::steady_clock::Duration DEFAULT_RESET_TIMER;
   static const time::steady_clock::Duration DEFAULT_CANCEL_RESET_TIMER;
   static const time::milliseconds DEFAULT_RESET_INTEREST_LIFETIME;
@@ -512,10 +507,10 @@
   static int s_instanceCounter;
 };
 
-#ifdef CHRONOSYNC_HAVE_TESTS
+#ifdef CHRONOSYNC_WITH_TESTS
 size_t
 getMaxPacketLimit();
-#endif // CHRONOSYNC_HAVE_TESTS
+#endif // CHRONOSYNC_WITH_TESTS
 
 } // namespace chronosync
 
diff --git a/src/socket.cpp b/src/socket.cpp
index 9aca2e5..46dc8dd 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-2019 University of California, Los Angeles
+ * Copyright (c) 2012-2021 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -23,9 +23,10 @@
  */
 
 #include "socket.hpp"
-#include "logger.hpp"
 
-INIT_LOGGER(Socket);
+#include <ndn-cxx/util/logger.hpp>
+
+NDN_LOG_INIT(sync.Socket);
 
 namespace chronosync {
 
@@ -55,7 +56,7 @@
     m_registeredPrefixList[m_userPrefix] =
       m_face.setInterestFilter(m_userPrefix,
                                bind(&Socket::onInterest, this, _1, _2),
-                               [] (const Name& prefix, const std::string& msg) {});
+                               [] (const Name&, const std::string&) {});
   NDN_LOG_DEBUG("<< Socket::Socket");
 }
 
@@ -84,7 +85,8 @@
   m_registeredPrefixList[prefix] =
     m_face.setInterestFilter(prefix,
                              bind(&Socket::onInterest, this, _1, _2),
-                             [] (const Name& prefix, const std::string& msg) {});
+                             [] (const Name&, const std::string&) {});
+
   NDN_LOG_DEBUG("<< addSyncNode");
 }
 
@@ -194,7 +196,7 @@
                   const ndn::TimeoutCallback& onTimeout,
                   int nRetries)
 {
-  _LOG_DEBUG(">> Socket::fetchData");
+  NDN_LOG_DEBUG(">> Socket::fetchData");
   Name interestName;
   interestName.append(sessionName).appendNumber(seqNo);
 
@@ -207,24 +209,24 @@
                          bind(onTimeout, _1), // Nack
                          onTimeout);
 
-  _LOG_DEBUG("<< Socket::fetchData");
+  NDN_LOG_DEBUG("<< Socket::fetchData");
 }
 
 void
-Socket::onInterest(const Name& prefix, const Interest& interest)
+Socket::onInterest(const Name&, const Interest& interest)
 {
-  shared_ptr<const Data> data = m_ims.find(interest);
+  auto data = m_ims.find(interest);
   if (data != nullptr) {
     m_face.put(*data);
   }
 }
 
 void
-Socket::onData(const Interest& interest, const Data& data,
+Socket::onData(const Interest&, const Data& data,
                const DataValidatedCallback& onValidated,
                const DataValidationErrorCallback& onFailed)
 {
-  _LOG_DEBUG("Socket::onData");
+  NDN_LOG_DEBUG("Socket::onData");
 
   if (static_cast<bool>(m_validator))
     m_validator->validate(data, onValidated, onFailed);
@@ -237,7 +239,8 @@
                       const DataValidatedCallback& onValidated,
                       const DataValidationErrorCallback& onFailed)
 {
-  _LOG_DEBUG("Socket::onDataTimeout");
+  NDN_LOG_DEBUG("Socket::onDataTimeout");
+
   if (nRetries <= 0)
     return;