face: Introduce Face-specific logging macros
Change-Id: I169065de664d4c4394ccd08673bbe1f881c4d7e0
Refs: #2450
diff --git a/daemon/face/websocket-face.cpp b/daemon/face/websocket-face.cpp
index 4875f6c..27a8f57 100644
--- a/daemon/face/websocket-face.cpp
+++ b/daemon/face/websocket-face.cpp
@@ -37,6 +37,7 @@
, m_server(server)
, m_closed(false)
{
+ NFD_LOG_FACE_INFO("Creating face");
this->setOnDemand(true);
}
@@ -46,6 +47,8 @@
if (m_closed)
return;
+ NFD_LOG_FACE_TRACE(__func__);
+
this->emitSignal(onSendInterest, interest);
const Block& payload = interest.wireEncode();
@@ -56,7 +59,7 @@
websocketpp::frame::opcode::binary);
}
catch (const websocketpp::lib::error_code& e) {
- NFD_LOG_WARN("Failed to send Interest: " << e << " (" << e.message() << ")");
+ NFD_LOG_FACE_WARN("Failed to send Interest: " << e << " (" << e.message() << ")");
}
}
@@ -66,6 +69,8 @@
if (m_closed)
return;
+ NFD_LOG_FACE_TRACE(__func__);
+
this->emitSignal(onSendData, data);
const Block& payload = data.wireEncode();
@@ -76,22 +81,24 @@
websocketpp::frame::opcode::binary);
}
catch (const websocketpp::lib::error_code& e) {
- NFD_LOG_WARN("Failed to send Data: " << e << " (" << e.message() << ")");
+ NFD_LOG_FACE_WARN("Failed to send Data: " << e << " (" << e.message() << ")");
}
}
void
WebSocketFace::close()
{
- if (m_closed == false)
- {
- m_closed = true;
- scheduler::cancel(m_pingEventId);
- websocketpp::lib::error_code ecode;
- m_server.close(m_handle, websocketpp::close::status::normal, "closed by nfd", ecode);
+ if (m_closed)
+ return;
- fail("Face closed");
- }
+ NFD_LOG_FACE_INFO("Closing face");
+
+ m_closed = true;
+ scheduler::cancel(m_pingEventId);
+ websocketpp::lib::error_code ecode;
+ m_server.close(m_handle, websocketpp::close::status::normal, "closed by nfd", ecode);
+
+ fail("Face closed");
}
void
@@ -100,13 +107,11 @@
// Copy message into Face internal buffer
if (msg.size() > ndn::MAX_NDN_PACKET_SIZE)
{
- NFD_LOG_WARN("[id:" << this->getId()
- << "] Received WebSocket message is too big (" << msg.size() << " bytes)");
+ NFD_LOG_FACE_WARN("Received WebSocket message is too big (" << msg.size() << " bytes)");
return;
}
- NFD_LOG_TRACE("[id:" << this->getId()
- << "] Received: " << msg.size() << " bytes");
+ NFD_LOG_FACE_TRACE("Received: " << msg.size() << " bytes");
this->getMutableCounters().getNInBytes() += msg.size();
// Try to parse message data
@@ -115,15 +120,13 @@
msg.size(), element);
if (!isOk)
{
- NFD_LOG_WARN("[id:" << this->getId()
- << "] Received block is invalid or too large to process");
+ NFD_LOG_FACE_WARN("Received block is invalid or too large to process");
return;
}
if (!this->decodeAndDispatchInput(element))
{
- NFD_LOG_WARN("[id:" << this->getId()
- << "] Received unrecognized TLV block of type " << element.type());
+ NFD_LOG_FACE_WARN("Received unrecognized TLV block of type " << element.type());
// ignore unknown packet and proceed
}
}