transport: add logging to TcpTransport

refs #3563

Change-Id: I510ae330b0baa46c4101b26f0f8087b7424376a4
diff --git a/src/transport/stream-transport-with-resolver-impl.hpp b/src/transport/stream-transport-with-resolver-impl.hpp
index ede8444..b9150d8 100644
--- a/src/transport/stream-transport-with-resolver-impl.hpp
+++ b/src/transport/stream-transport-with-resolver-impl.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -33,7 +33,7 @@
 class StreamTransportWithResolverImpl : public StreamTransportImpl<BaseTransport, Protocol>
 {
 public:
-  typedef StreamTransportWithResolverImpl<BaseTransport,Protocol> Impl;
+  using Impl = StreamTransportWithResolverImpl<BaseTransport,Protocol>;
 
   StreamTransportWithResolverImpl(BaseTransport& transport, boost::asio::io_service& ioService)
     : StreamTransportImpl<BaseTransport, Protocol>(transport, ioService)
@@ -54,7 +54,6 @@
     this->m_connectTimer.expires_from_now(boost::posix_time::seconds(4));
     this->m_connectTimer.async_wait(bind(&Impl::connectTimeoutHandler, this->shared_from_this(), _1));
 
-    // typename boost::asio::ip::basic_resolver< Protocol > resolver;
     auto resolver = make_shared<typename Protocol::resolver>(ref(this->m_socket.get_io_service()));
     resolver->async_resolve(query, bind(&Impl::resolveHandler, this->shared_from_base(), _1, _2, resolver));
   }
@@ -75,7 +74,7 @@
     typename Protocol::resolver::iterator end;
     if (endpoint == end) {
       this->m_transport.close();
-      BOOST_THROW_EXCEPTION(Transport::Error(error, "Unable to resolve because host or port"));
+      BOOST_THROW_EXCEPTION(Transport::Error(error, "Unable to resolve host or port"));
     }
 
     this->m_socket.async_connect(*endpoint, bind(&Impl::connectHandler, this->shared_from_this(), _1));
diff --git a/src/transport/tcp-transport.cpp b/src/transport/tcp-transport.cpp
index 7fb6341..8b99f3e 100644
--- a/src/transport/tcp-transport.cpp
+++ b/src/transport/tcp-transport.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -22,6 +22,10 @@
 #include "tcp-transport.hpp"
 #include "stream-transport-with-resolver-impl.hpp"
 #include "net/face-uri.hpp"
+#include "util/logger.hpp"
+
+NDN_LOG_INIT(ndn.TcpTransport);
+// DEBUG level: connect, close, pause, resume.
 
 namespace ndn {
 
@@ -77,6 +81,8 @@
 TcpTransport::connect(boost::asio::io_service& ioService,
                       const ReceiveCallback& receiveCallback)
 {
+  NDN_LOG_DEBUG("connect host=" << m_host << " port=" << m_port);
+
   if (m_impl == nullptr) {
     Transport::connect(ioService, receiveCallback);
 
@@ -105,6 +111,7 @@
 TcpTransport::close()
 {
   BOOST_ASSERT(m_impl != nullptr);
+  NDN_LOG_DEBUG("close");
   m_impl->close();
   m_impl.reset();
 }
@@ -113,6 +120,7 @@
 TcpTransport::pause()
 {
   if (m_impl != nullptr) {
+    NDN_LOG_DEBUG("pause");
     m_impl->pause();
   }
 }
@@ -121,6 +129,7 @@
 TcpTransport::resume()
 {
   BOOST_ASSERT(m_impl != nullptr);
+  NDN_LOG_DEBUG("resume");
   m_impl->resume();
 }
 
diff --git a/src/transport/tcp-transport.hpp b/src/transport/tcp-transport.hpp
index 57004bc..d9ed7f2 100644
--- a/src/transport/tcp-transport.hpp
+++ b/src/transport/tcp-transport.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -52,8 +52,7 @@
   ~TcpTransport() override;
 
   void
-  connect(boost::asio::io_service& ioService,
-          const ReceiveCallback& receiveCallback) override;
+  connect(boost::asio::io_service& ioService, const ReceiveCallback& receiveCallback) override;
 
   void
   close() override;
@@ -84,9 +83,9 @@
   std::string m_host;
   std::string m_port;
 
-  typedef StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp> Impl;
+  using Impl = StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp>;
   friend class StreamTransportImpl<TcpTransport, boost::asio::ip::tcp>;
-  friend class StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp>;
+  friend Impl;
   shared_ptr<Impl> m_impl;
 };