src: Adding log4cxx logging
Refs: #1505
Change-Id: Ib154d91f81acf3f1dd8bbcf552062a16d03fec74
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index bcfb61c..21ac00c 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -9,9 +9,12 @@
#include "routing-table-calculator.hpp"
#include "routing-table-entry.hpp"
#include "name-prefix-table.hpp"
+#include "logger.hpp"
namespace nlsr {
+INIT_LOGGER("RoutingTable");
+
using namespace std;
void
@@ -22,6 +25,7 @@
pnlsr.getLsdb().printAdjLsdb();
pnlsr.getLsdb().printCorLsdb();
pnlsr.getLsdb().printNameLsdb();
+ pnlsr.getNamePrefixTable().writeLog();
if (pnlsr.getIsRoutingTableCalculating() == false) {
//setting routing table calculation
pnlsr.setIsRoutingTableCalculating(true);
@@ -30,6 +34,7 @@
std::string("adjacency"))) {
if (pnlsr.getIsBuildAdjLsaSheduled() != 1) {
std::cout << "CLearing old routing table ....." << std::endl;
+ _LOG_DEBUG("CLearing old routing table .....");
clearRoutingTable();
// for dry run options
clearDryRoutingTable();
@@ -52,16 +57,23 @@
printRoutingTable();
pnlsr.getNamePrefixTable().print();
pnlsr.getFib().print();
+ writeLog();
+ pnlsr.getNamePrefixTable().writeLog();
+ pnlsr.getFib().writeLog();
//debugging purpose end
}
else {
std::cout << "Adjacency building is scheduled, so ";
std::cout << "routing table can not be calculated :(" << std::endl;
+ _LOG_DEBUG("Adjacency building is scheduled, so"
+ " routing table can not be calculated :(");
}
}
else {
std::cout << "No Adj LSA of router itself,";
std::cout << " so Routing table can not be calculated :(" << std::endl;
+ _LOG_DEBUG("No Adj LSA of router itself,"
+ " so Routing table can not be calculated :(");
clearRoutingTable();
clearDryRoutingTable(); // for dry run options
// need to update NPT here
@@ -71,6 +83,9 @@
printRoutingTable();
pnlsr.getNamePrefixTable().print();
pnlsr.getFib().print();
+ writeLog();
+ pnlsr.getNamePrefixTable().writeLog();
+ pnlsr.getFib().writeLog();
//debugging purpose end
}
pnlsr.setIsRouteCalculationScheduled(false); //clear scheduled flag
@@ -159,6 +174,18 @@
}
void
+RoutingTable::writeLog()
+{
+ _LOG_DEBUG("---------------Routing Table------------------");
+ for (std::list<RoutingTableEntry>::iterator it = m_rTable.begin() ;
+ it != m_rTable.end(); ++it) {
+ _LOG_DEBUG("Destination: " << (*it).getDestination());
+ _LOG_DEBUG("Nexthops: ");
+ (*it).getNexthopList().writeLog();
+ }
+}
+
+void
RoutingTable::printRoutingTable()
{
std::cout << "---------------Routing Table------------------" << std::endl;