mgmt+rib: improve logging
Change-Id: I2c8470831a9f9cbd5c06681f69783c4b442420f9
diff --git a/daemon/rib/fib-updater.cpp b/daemon/rib/fib-updater.cpp
index 897b6fb..0b8fc0e 100644
--- a/daemon/rib/fib-updater.cpp
+++ b/daemon/rib/fib-updater.cpp
@@ -64,24 +64,23 @@
void
FibUpdater::computeUpdates(const RibUpdateBatch& batch)
{
- NFD_LOG_DEBUG("Computing updates for batch with faceID: " << batch.getFaceId());
+ NFD_LOG_TRACE("Computing updates for batch with faceid=" << batch.getFaceId());
// Compute updates and add to m_fibUpdates
for (const RibUpdate& update : batch) {
switch (update.getAction()) {
- case RibUpdate::REGISTER:
- computeUpdatesForRegistration(update);
- break;
- case RibUpdate::UNREGISTER:
- computeUpdatesForUnregistration(update);
- break;
- case RibUpdate::REMOVE_FACE:
- computeUpdatesForUnregistration(update);
-
- // Do not apply updates with the same face ID as the destroyed face
- // since they will be rejected by the FIB
- m_updatesForBatchFaceId.clear();
- break;
+ case RibUpdate::REGISTER:
+ computeUpdatesForRegistration(update);
+ break;
+ case RibUpdate::UNREGISTER:
+ computeUpdatesForUnregistration(update);
+ break;
+ case RibUpdate::REMOVE_FACE:
+ computeUpdatesForUnregistration(update);
+ // Do not apply updates with the same face ID as the destroyed face
+ // since they will be rejected by the FIB
+ m_updatesForBatchFaceId.clear();
+ break;
}
}
}
diff --git a/daemon/rib/readvertise/readvertise.cpp b/daemon/rib/readvertise/readvertise.cpp
index 164e26b..1df539d 100644
--- a/daemon/rib/readvertise/readvertise.cpp
+++ b/daemon/rib/readvertise/readvertise.cpp
@@ -68,16 +68,16 @@
{
std::optional<ReadvertiseAction> action = m_policy->handleNewRoute(ribRoute);
if (!action) {
- NFD_LOG_DEBUG("add-route " << ribRoute.entry->getName() << '(' << ribRoute.route->faceId <<
- ',' << ribRoute.route->origin << ") not-readvertising");
+ NFD_LOG_DEBUG("add-route " << ribRoute.entry->getName() << " face=" << ribRoute.route->faceId <<
+ " origin=" << ribRoute.route->origin << " -> not-readvertising");
return;
}
auto [rrIt, isNewRr] = m_rrs.emplace(action->prefix);
if (!isNewRr && rrIt->signer != action->signer) {
- NFD_LOG_WARN("add-route " << ribRoute.entry->getName() << '(' << ribRoute.route->faceId <<
- ',' << ribRoute.route->origin << ") readvertising-as " << action->prefix <<
- " old-signer " << rrIt->signer << " new-signer " << action->signer);
+ NFD_LOG_WARN("add-route " << ribRoute.entry->getName() << " face=" << ribRoute.route->faceId <<
+ " origin=" << ribRoute.route->origin << " -> readvertising-as " << action->prefix <<
+ " old-signer=" << rrIt->signer << " new-signer=" << action->signer);
}
rrIt->signer = action->signer;
@@ -85,14 +85,14 @@
BOOST_VERIFY(isNewInMap);
if (rrIt->nRibRoutes++ > 0) {
- NFD_LOG_DEBUG("add-route " << ribRoute.entry->getName() << '(' << ribRoute.route->faceId <<
- ',' << ribRoute.route->origin << ") already-readvertised-as " << action->prefix);
+ NFD_LOG_DEBUG("add-route " << ribRoute.entry->getName() << " face=" << ribRoute.route->faceId <<
+ " origin=" << ribRoute.route->origin << " -> already-readvertised-as " << action->prefix);
return;
}
- NFD_LOG_DEBUG("add-route " << ribRoute.entry->getName() << '(' << ribRoute.route->faceId <<
- ',' << ribRoute.route->origin << ") readvertising-as " << action->prefix <<
- " signer " << action->signer);
+ NFD_LOG_DEBUG("add-route " << ribRoute.entry->getName() << " face=" << ribRoute.route->faceId <<
+ " origin=" << ribRoute.route->origin << " -> readvertising-as " << action->prefix <<
+ " signer=" << action->signer);
rrIt->retryDelay = RETRY_DELAY_MIN;
this->advertise(rrIt);
}
@@ -102,8 +102,8 @@
{
auto indexIt = m_routeToRr.find(ribRoute);
if (indexIt == m_routeToRr.end()) {
- NFD_LOG_DEBUG("remove-route " << ribRoute.entry->getName() << '(' << ribRoute.route->faceId <<
- ',' << ribRoute.route->origin << ") not-readvertised");
+ NFD_LOG_DEBUG("remove-route " << ribRoute.entry->getName() << " face=" << ribRoute.route->faceId <<
+ " origin=" << ribRoute.route->origin << " -> not-readvertised");
return;
}
@@ -111,8 +111,8 @@
m_routeToRr.erase(indexIt);
if (--rrIt->nRibRoutes > 0) {
- NFD_LOG_DEBUG("remove-route " << ribRoute.entry->getName() << '(' << ribRoute.route->faceId <<
- ',' << ribRoute.route->origin << ") needed-by " << rrIt->nRibRoutes);
+ NFD_LOG_DEBUG("remove-route " << ribRoute.entry->getName() << " face=" << ribRoute.route->faceId <<
+ " origin=" << ribRoute.route->origin << " -> needed-by " << rrIt->nRibRoutes);
return;
}
@@ -149,19 +149,19 @@
BOOST_ASSERT(rrIt->nRibRoutes > 0);
if (!m_destination->isAvailable()) {
- NFD_LOG_DEBUG("advertise " << rrIt->prefix << " destination-unavailable");
+ NFD_LOG_DEBUG("advertise " << rrIt->prefix << " -> destination unavailable");
return;
}
m_destination->advertise(*rrIt,
[=] {
- NFD_LOG_DEBUG("advertise " << rrIt->prefix << " success");
+ NFD_LOG_DEBUG("advertise " << rrIt->prefix << " -> success");
rrIt->retryDelay = RETRY_DELAY_MIN;
rrIt->retryEvt = getScheduler().schedule(randomizeTimer(m_policy->getRefreshInterval()),
[=] { advertise(rrIt); });
},
[=] (const std::string& msg) {
- NFD_LOG_DEBUG("advertise " << rrIt->prefix << " failure: " << msg);
+ NFD_LOG_DEBUG("advertise " << rrIt->prefix << " -> failure: " << msg);
rrIt->retryDelay = std::min(RETRY_DELAY_MAX, rrIt->retryDelay * 2);
rrIt->retryEvt = getScheduler().schedule(randomizeTimer(rrIt->retryDelay),
[=] { advertise(rrIt); });
@@ -174,18 +174,18 @@
BOOST_ASSERT(rrIt->nRibRoutes == 0);
if (!m_destination->isAvailable()) {
- NFD_LOG_DEBUG("withdraw " << rrIt->prefix << " destination-unavailable");
+ NFD_LOG_DEBUG("withdraw " << rrIt->prefix << " -> destination unavailable");
m_rrs.erase(rrIt);
return;
}
m_destination->withdraw(*rrIt,
[=] {
- NFD_LOG_DEBUG("withdraw " << rrIt->prefix << " success");
+ NFD_LOG_DEBUG("withdraw " << rrIt->prefix << " -> success");
m_rrs.erase(rrIt);
},
[=] (const std::string& msg) {
- NFD_LOG_DEBUG("withdraw " << rrIt->prefix << " failure: " << msg);
+ NFD_LOG_DEBUG("withdraw " << rrIt->prefix << " -> failure: " << msg);
rrIt->retryDelay = std::min(RETRY_DELAY_MAX, rrIt->retryDelay * 2);
rrIt->retryEvt = getScheduler().schedule(randomizeTimer(rrIt->retryDelay),
[=] { withdraw(rrIt); });
diff --git a/daemon/rib/rib-update.cpp b/daemon/rib/rib-update.cpp
index 935ccce..8fc5000 100644
--- a/daemon/rib/rib-update.cpp
+++ b/daemon/rib/rib-update.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2025, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -44,10 +44,9 @@
std::ostream&
operator<<(std::ostream& os, const RibUpdate& update)
{
- return os << "RibUpdate {\n"
- << " Name: " << update.getName() << "\n"
- << " Action: " << update.getAction() << "\n"
- << " " << update.getRoute() << "\n"
+ return os << "RibUpdate{" << update.getAction()
+ << ", " << update.getName()
+ << ", " << update.getRoute()
<< "}";
}
diff --git a/daemon/rib/route.cpp b/daemon/rib/route.cpp
index 5011290..642aa1e 100644
--- a/daemon/rib/route.cpp
+++ b/daemon/rib/route.cpp
@@ -35,13 +35,14 @@
computeExpiration(const ndn::PrefixAnnouncement& ann)
{
auto validityEnd = time::steady_clock::duration::max();
- if (ann.getValidityPeriod()) {
+ const auto& validityPeriod = ann.getValidityPeriod();
+ if (validityPeriod) {
auto now = time::system_clock::now();
- if (!ann.getValidityPeriod()->isValid(now)) {
+ if (!validityPeriod->isValid(now)) {
validityEnd = time::steady_clock::duration::zero();
}
else {
- validityEnd = ann.getValidityPeriod()->getPeriod().second - now;
+ validityEnd = validityPeriod->getPeriod().second - now;
}
}
return time::steady_clock::now() +
@@ -62,8 +63,8 @@
std::ostream&
operator<<(std::ostream& os, const Route& route)
{
- os << "Route("
- << "faceid: " << route.faceId
+ os << "Route{"
+ << "face: " << route.faceId
<< ", origin: " << route.origin
<< ", cost: " << route.cost
<< ", flags: " << ndn::AsHex{route.flags};
@@ -72,14 +73,14 @@
os << ", expires in: " << time::duration_cast<time::milliseconds>(*route.expires - time::steady_clock::now());
}
else {
- os << ", never expires";
+ os << ", expires: never";
}
if (route.announcement) {
os << ", announcement: (" << *route.announcement << ')';
}
- return os << ')';
+ return os << '}';
}
} // namespace nfd::rib