Adding extended logging in ccnx-wrapper
diff --git a/ccnx/ccnx-wrapper.cpp b/ccnx/ccnx-wrapper.cpp
index 697901c..bdb40e7 100644
--- a/ccnx/ccnx-wrapper.cpp
+++ b/ccnx/ccnx-wrapper.cpp
@@ -205,15 +205,24 @@
int
CcnxWrapper::putToCcnd (const Bytes &contentObject)
{
+ _LOG_TRACE (">> putToCcnd");
UniqueRecLock lock(m_mutex);
if (!m_running || !m_connected)
- return -1;
+ {
+ _LOG_TRACE ("<< not running or connected");
+ return -1;
+ }
if (ccn_put(m_handle, head(contentObject), contentObject.size()) < 0)
{
+ _LOG_ERROR ("ccn_put failed");
// BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("ccnput failed"));
}
+ else
+ {
+ _LOG_DEBUG ("<< putToCcnd");
+ }
return 0;
}
@@ -238,24 +247,29 @@
ccn_upcall_info *info)
{
CcnxWrapper::InterestCallback *f = static_cast<CcnxWrapper::InterestCallback*> (selfp->data);
+ _LOG_TRACE (">> incomingInterest upcall");
switch (kind)
{
case CCN_UPCALL_FINAL: // effective in unit tests
delete f;
delete selfp;
+ _LOG_TRACE ("<< incomingInterest with CCN_UPCALL_FINAL");
return CCN_UPCALL_RESULT_OK;
case CCN_UPCALL_INTEREST:
break;
default:
+ _LOG_TRACE ("<< incomingInterest with CCN_UPCALL_RESULT_OK");
return CCN_UPCALL_RESULT_OK;
}
Name interest(info->interest_ccnb, info->interest_comps);
(*f) (interest);
+
+ _LOG_TRACE ("<< incomingInterest");
return CCN_UPCALL_RESULT_OK;
}
@@ -265,6 +279,7 @@
ccn_upcall_info *info)
{
Closure *cp = static_cast<Closure *> (selfp->data);
+ _LOG_TRACE (">> incomingData upcall");
switch (kind)
{
@@ -272,6 +287,7 @@
delete cp;
cp = NULL;
delete selfp;
+ _LOG_TRACE ("<< incomingData with CCN_UPCALL_FINAL");
return CCN_UPCALL_RESULT_OK;
case CCN_UPCALL_CONTENT:
@@ -280,6 +296,7 @@
case CCN_UPCALL_INTEREST_TIMED_OUT: {
if (cp != NULL)
{
+ _LOG_TRACE ("<< incomingData timeout");
Name interest(info->interest_ccnb, info->interest_comps);
Closure::TimeoutCallbackReturnValue rv = cp->runTimeoutCallback(interest);
switch(rv)
@@ -289,6 +306,10 @@
default : break;
}
}
+ else
+ {
+ _LOG_TRACE ("<< incomingData timeout, but callback is not set...");
+ }
return CCN_UPCALL_RESULT_OK;
}
@@ -314,14 +335,20 @@
cp->runDataCallback (pco->name (), pco);
+ _LOG_TRACE (">> incomingData");
+
return CCN_UPCALL_RESULT_OK;
}
int CcnxWrapper::sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors)
{
+ _LOG_TRACE (">> sendInterest");
UniqueRecLock lock(m_mutex);
if (!m_running || !m_connected)
- return -1;
+ {
+ _LOG_ERROR ("<< sendInterest: not running or connected");
+ return -1;
+ }
CcnxCharbufPtr namePtr = interest.toCcnxCharbuf();
ccn_charbuf *pname = namePtr->getBuf();
@@ -341,13 +368,17 @@
if (ccn_express_interest (m_handle, pname, dataClosure, templ) < 0)
{
+ _LOG_ERROR ("<< sendInterest: ccn_express_interest FAILED!!!");
}
+ _LOG_TRACE ("<< sendInterest");
+
return 0;
}
int CcnxWrapper::setInterestFilter (const Name &prefix, const InterestCallback &interestCallback)
{
+ _LOG_TRACE (">> setInterestFilter");
UniqueRecLock lock(m_mutex);
if (!m_running || !m_connected)
return -1;
@@ -361,9 +392,12 @@
int ret = ccn_set_interest_filter (m_handle, pname, interestClosure);
if (ret < 0)
{
+ _LOG_ERROR ("<< setInterestFilter: ccn_set_interest_filter FAILED");
}
m_registeredInterests.insert(pair<Name, InterestCallback>(prefix, interestCallback));
+
+ _LOG_TRACE ("<< setInterestFilter");
return ret;
}
@@ -371,6 +405,7 @@
void
CcnxWrapper::clearInterestFilter (const Name &prefix)
{
+ _LOG_TRACE (">> clearInterestFilter");
UniqueRecLock lock(m_mutex);
if (!m_running || !m_connected)
return;
@@ -384,6 +419,8 @@
}
m_registeredInterests.erase(prefix);
+
+ _LOG_TRACE ("<< clearInterestFilter");
}
Name