face: make logging more uniform across channel types
Change-Id: I21db45f736e07464260dcc902c673d098ba3c549
Refs: #2561
diff --git a/daemon/face/unix-stream-channel.cpp b/daemon/face/unix-stream-channel.cpp
index b253a70..87af308 100644
--- a/daemon/face/unix-stream-channel.cpp
+++ b/daemon/face/unix-stream-channel.cpp
@@ -43,6 +43,7 @@
, m_size(0)
{
setUri(FaceUri(m_endpoint));
+ NFD_LOG_CHAN_INFO("Creating channel");
}
UnixStreamChannel::~UnixStreamChannel()
@@ -52,7 +53,7 @@
// and ignore any errors
boost::system::error_code error;
m_acceptor.close(error);
- NFD_LOG_DEBUG("[" << m_endpoint << "] Removing socket file");
+ NFD_LOG_CHAN_DEBUG("Removing socket file");
boost::filesystem::remove(m_endpoint.path(), error);
}
}
@@ -63,7 +64,7 @@
int backlog/* = acceptor::max_connections*/)
{
if (isListening()) {
- NFD_LOG_WARN("[" << m_endpoint << "] Already listening");
+ NFD_LOG_CHAN_WARN("Already listening");
return;
}
@@ -76,8 +77,7 @@
boost::system::error_code error;
boost::asio::local::stream_protocol::socket socket(getGlobalIoService());
socket.connect(m_endpoint, error);
- NFD_LOG_TRACE("[" << m_endpoint << "] connect() on existing socket file returned: "
- + error.message());
+ NFD_LOG_CHAN_TRACE("connect() on existing socket file returned: " << error.message());
if (!error) {
// someone answered, leave the socket alone
BOOST_THROW_EXCEPTION(Error("Socket file at " + m_endpoint.path()
@@ -87,7 +87,7 @@
error == boost::asio::error::timed_out) {
// no one is listening on the remote side,
// we can safely remove the stale socket
- NFD_LOG_DEBUG("[" << m_endpoint << "] Removing stale socket file");
+ NFD_LOG_CHAN_DEBUG("Removing stale socket file");
fs::remove(socketPath);
}
}
@@ -100,12 +100,11 @@
m_acceptor.listen(backlog);
if (::chmod(m_endpoint.path().c_str(), 0666) < 0) {
- BOOST_THROW_EXCEPTION(Error("chmod(" + m_endpoint.path() + ") failed: " +
- std::strerror(errno)));
+ BOOST_THROW_EXCEPTION(Error("chmod(" + m_endpoint.path() + ") failed: " + std::strerror(errno)));
}
- // start accepting connections
accept(onFaceCreated, onAcceptFailed);
+ NFD_LOG_CHAN_DEBUG("Started listening");
}
void
@@ -123,16 +122,15 @@
const FaceCreationFailedCallback& onAcceptFailed)
{
if (error) {
- if (error == boost::asio::error::operation_aborted) // when the socket is closed by someone
- return;
-
- NFD_LOG_DEBUG("[" << m_endpoint << "] Accept failed: " << error.message());
- if (onAcceptFailed)
- onAcceptFailed(500, "Accept failed: " + error.message());
+ if (error != boost::asio::error::operation_aborted) {
+ NFD_LOG_CHAN_DEBUG("Accept failed: " << error.message());
+ if (onAcceptFailed)
+ onAcceptFailed(500, "Accept failed: " + error.message());
+ }
return;
}
- NFD_LOG_DEBUG("[" << m_endpoint << "] Incoming connection");
+ NFD_LOG_CHAN_TRACE("Incoming connection via fd " << m_socket.native_handle());
auto linkService = make_unique<GenericLinkService>();
auto transport = make_unique<UnixStreamTransport>(std::move(m_socket));