core: change logging from environment variable to configuration file-based
GlobalConfigurationFixture uses unit-tests.conf to determine default
and module specific logging levels. Logging will gracefully default to
INFO if unit-tests.conf is not found. See unit-tests.conf.sample for a
sample configuration file.
refs: #1375, #1267
Change-Id: Ib0c4eb4149748e6658f94ef1afa23ddd3072c0fa
diff --git a/daemon/face/datagram-face.hpp b/daemon/face/datagram-face.hpp
index cbda459..f59374f 100644
--- a/daemon/face/datagram-face.hpp
+++ b/daemon/face/datagram-face.hpp
@@ -8,6 +8,7 @@
#define NFD_FACE_DATAGRAM_FACE_HPP
#include "face.hpp"
+#include "core/logger.hpp"
namespace nfd {
@@ -30,14 +31,14 @@
virtual
~DatagramFace();
-
+
// from Face
virtual void
sendInterest(const Interest& interest);
-
+
virtual void
sendData(const Data& data);
-
+
virtual void
close();
@@ -54,13 +55,13 @@
*/
void
resetRecentUsage();
-
+
bool
hasBeenUsedRecently() const;
void
setOnDemand(bool isOnDemand);
-
+
protected:
void
receiveDatagram(const uint8_t* buffer,
@@ -69,10 +70,10 @@
void
keepFaceAliveUntilAllHandlersExecuted(const shared_ptr<Face>& face);
-
+
void
closeSocket();
-
+
protected:
shared_ptr<typename protocol::socket> m_socket;
uint8_t m_inputBuffer[MAX_NDN_PACKET_SIZE];
@@ -101,7 +102,7 @@
DatagramFace<T>::~DatagramFace()
{
}
-
+
template <class T>
inline void
DatagramFace<T>::sendInterest(const Interest& interest)
@@ -110,10 +111,10 @@
m_socket->async_send(boost::asio::buffer(interest.wireEncode().wire(),
interest.wireEncode().size()),
bind(&DatagramFace<T>::handleSend, this, _1, interest.wireEncode()));
-
+
// anything else should be done here?
}
-
+
template <class T>
inline void
DatagramFace<T>::sendData(const Data& data)
@@ -122,7 +123,7 @@
m_socket->async_send(boost::asio::buffer(data.wireEncode().wire(),
data.wireEncode().size()),
bind(&DatagramFace<T>::handleSend, this, _1, data.wireEncode()));
-
+
// anything else should be done here?
}
@@ -134,20 +135,20 @@
if (error != 0) {
if (error == boost::system::errc::operation_canceled) // when socket is closed by someone
return;
-
+
if (!m_socket->is_open())
{
onFail("Tunnel closed");
return;
}
-
+
NFD_LOG_WARN("[id:" << this->getId()
<< ",endpoint:" << m_socket->local_endpoint()
<< "] Send operation failed, closing socket: "
<< error.category().message(error.value()));
-
+
closeSocket();
-
+
if (error == boost::asio::error::eof)
{
onFail("Tunnel closed");
@@ -159,24 +160,24 @@
}
return;
}
-
+
NFD_LOG_TRACE("[id:" << this->getId()
<< ",endpoint:" << m_socket->local_endpoint()
<< "] Successfully sent: " << wire.size() << " bytes");
// do nothing (needed to retain validity of wire memory block
}
-
+
template <class T>
inline void
DatagramFace<T>::close()
{
if (!m_socket->is_open())
return;
-
+
NFD_LOG_INFO("[id:" << this->getId()
<< ",endpoint:" << m_socket->local_endpoint()
<< "] Close tunnel");
-
+
closeSocket();
onFail("Close tunnel");
}
@@ -273,20 +274,20 @@
DatagramFace<T>::keepFaceAliveUntilAllHandlersExecuted(const shared_ptr<Face>& face)
{
}
-
+
template <class T>
inline void
DatagramFace<T>::closeSocket()
{
NFD_LOG_DEBUG("closeSocket " << m_socket->local_endpoint());
boost::asio::io_service& io = m_socket->get_io_service();
-
+
// use the non-throwing variants and ignore errors, if any
boost::system::error_code error;
m_socket->shutdown(protocol::socket::shutdown_both, error);
m_socket->close(error);
// after this, handlers will be called with an error code
-
+
// ensure that the Face object is alive at least until all pending
// handlers are dispatched
io.post(bind(&DatagramFace<T>::keepFaceAliveUntilAllHandlersExecuted,
diff --git a/daemon/face/ethernet-face.cpp b/daemon/face/ethernet-face.cpp
index e619724..66dcf08 100644
--- a/daemon/face/ethernet-face.cpp
+++ b/daemon/face/ethernet-face.cpp
@@ -5,6 +5,7 @@
*/
#include "ethernet-face.hpp"
+#include "core/logger.hpp"
#include "core/network-interface.hpp"
#include <pcap/pcap.h>
diff --git a/daemon/face/ethernet-factory.cpp b/daemon/face/ethernet-factory.cpp
index 2801c4f..4b1d8c1 100644
--- a/daemon/face/ethernet-factory.cpp
+++ b/daemon/face/ethernet-factory.cpp
@@ -5,6 +5,7 @@
*/
#include "ethernet-factory.hpp"
+#include "core/logger.hpp"
#include "core/global-io.hpp"
#include "core/network-interface.hpp"
diff --git a/daemon/face/multicast-udp-face.cpp b/daemon/face/multicast-udp-face.cpp
index b5632e2..34d40f0 100644
--- a/daemon/face/multicast-udp-face.cpp
+++ b/daemon/face/multicast-udp-face.cpp
@@ -33,7 +33,7 @@
interest.wireEncode().size()),
m_multicastGroup,
bind(&DatagramFace<protocol>::handleSend, this, _1, interest.wireEncode()));
-
+
// anything else should be done here?
}
diff --git a/daemon/face/stream-face.hpp b/daemon/face/stream-face.hpp
index a1aa7c1..1b5b124 100644
--- a/daemon/face/stream-face.hpp
+++ b/daemon/face/stream-face.hpp
@@ -9,6 +9,7 @@
#include "face.hpp"
#include "local-face.hpp"
+#include "core/logger.hpp"
namespace nfd {