face: make logging more uniform across channel types
Change-Id: I21db45f736e07464260dcc902c673d098ba3c549
Refs: #2561
diff --git a/daemon/face/websocket-channel.cpp b/daemon/face/websocket-channel.cpp
index daf362c..02ae079 100644
--- a/daemon/face/websocket-channel.cpp
+++ b/daemon/face/websocket-channel.cpp
@@ -35,9 +35,10 @@
WebSocketChannel::WebSocketChannel(const websocket::Endpoint& localEndpoint)
: m_localEndpoint(localEndpoint)
- , m_pingInterval(10000)
+ , m_pingInterval(time::seconds(10))
{
setUri(FaceUri(m_localEndpoint, "ws"));
+ NFD_LOG_CHAN_INFO("Creating channel");
// Be quiet
m_server.clear_access_channels(websocketpp::log::alevel::all);
@@ -81,7 +82,7 @@
static_cast<WebSocketTransport*>(it->second->getTransport())->handlePongTimeout();
}
else {
- NFD_LOG_WARN("Pong timeout on unknown transport");
+ NFD_LOG_CHAN_WARN("Pong timeout on unknown transport");
}
}
@@ -93,7 +94,7 @@
static_cast<WebSocketTransport*>(it->second->getTransport())->handlePong();
}
else {
- NFD_LOG_WARN("Pong received on unknown transport");
+ NFD_LOG_CHAN_WARN("Pong received on unknown transport");
}
}
@@ -106,17 +107,20 @@
static_cast<WebSocketTransport*>(it->second->getTransport())->receiveMessage(msg->get_payload());
}
else {
- NFD_LOG_WARN("Message received on unknown transport");
+ NFD_LOG_CHAN_WARN("Message received on unknown transport");
}
}
void
WebSocketChannel::handleOpen(websocketpp::connection_hdl hdl)
{
+ NFD_LOG_CHAN_TRACE("Incoming connection from " << m_server.get_con_from_hdl(hdl)->get_remote_endpoint());
+
auto linkService = make_unique<GenericLinkService>();
auto transport = make_unique<WebSocketTransport>(hdl, ref(m_server), m_pingInterval);
auto face = make_shared<Face>(std::move(linkService), std::move(transport));
+ BOOST_ASSERT(m_channelFaces.count(hdl) == 0);
m_channelFaces[hdl] = face;
connectFaceClosedSignal(*face, [this, hdl] { m_channelFaces.erase(hdl); });
@@ -131,21 +135,23 @@
it->second->close();
}
else {
- NFD_LOG_WARN("Close on unknown transport");
+ NFD_LOG_CHAN_WARN("Close on unknown transport");
}
}
void
WebSocketChannel::listen(const FaceCreatedCallback& onFaceCreated)
{
- if (m_server.is_listening()) {
- NFD_LOG_WARN("[" << m_localEndpoint << "] Already listening");
+ if (isListening()) {
+ NFD_LOG_CHAN_WARN("Already listening");
return;
}
m_onFaceCreatedCallback = onFaceCreated;
+
m_server.listen(m_localEndpoint);
m_server.start_accept();
+ NFD_LOG_CHAN_DEBUG("Started listening");
}
} // namespace face