NLSR Logging by BOOST.Log added
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 4877cb7..444063a 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -3,13 +3,14 @@
#include <ndn-cpp-dev/util/scheduler.hpp>
#include <cstdlib>
-#include<string>
+#include <string>
#include <sstream>
#include "nlsr.hpp"
#include "nlsr_conf_param.hpp"
#include "nlsr_conf_processor.hpp"
#include "nlsr_lsdb.hpp"
+#include "nlsr_logger.hpp"
//test purpose of NLSR
#include "nlsr_test.hpp"
@@ -94,9 +95,14 @@
nlsr.getConfParameter().buildRouterPrefix();
nlsr.getNlsrLogger().initNlsrLogger(nlsr.getConfParameter().getLogDir());
+ //src::logger lg;
+ //BOOST_LOG(lg) << "Some log record from nlsr.cpp";
+ //for(int j=0; j< 1000; j++)
+ //{
+ // BOOST_LOG(lg) << "Some log record from nlsr.cpp "<<j;
+ //}
nlsr.getLsdb().setLsaRefreshTime(nlsr.getConfParameter().getLsaRefreshTime());
nlsr.getFib().setFibEntryRefreshTime(2*nlsr.getConfParameter().getLsaRefreshTime());
- //nlsr.getFib().scheduleFibRefreshing(nlsr, 60);
nlsr.getLsdb().setThisRouterPrefix(nlsr.getConfParameter().getRouterPrefix());
/* debugging purpose start */
@@ -108,11 +114,13 @@
nlsr.getLsdb().buildAndInstallOwnNameLsa(nlsr);
nlsr.getLsdb().buildAndInstallOwnCorLsa(nlsr);
- //testing purpose
- nlsr.getNlsrTesting().schedlueAddingLsas(nlsr);
+
+
nlsr.setInterestFilterNlsr(nlsr.getConfParameter().getRouterPrefix());
nlsr.getIm().scheduleInfoInterest(nlsr,1);
+ //testing purpose
+ nlsr.getNlsrTesting().schedlueAddingLsas(nlsr);
diff --git a/src/nlsr_logger.cpp b/src/nlsr_logger.cpp
index af263cd..055c00c 100644
--- a/src/nlsr_logger.cpp
+++ b/src/nlsr_logger.cpp
@@ -30,29 +30,31 @@
string logDirPath(dirPath);
if( dirPath.empty() )
{
- logDirPath=getUserHomeDirectory();
+ logDirPath=getUserHomeDirectory()+"/nlsrLog";
}
-
+ cout<<"Log Dir Path: "<< logDirPath<<endl;
+
+ //Create a text file sink
typedef sinks::synchronous_sink< sinks::text_file_backend > file_sink;
shared_ptr< file_sink > sink(new file_sink(
- keywords::file_name = "NLSR%Y%m%d%H%M%S_%3N.log", // file name pattern
- keywords::rotation_size = 128 * 1024 * 1024 ,// rotation size, in characters
- keywords::time_based_rotation = sinks::file::rotation_at_time_point(12, 0, 0)
+ keywords::file_name = logDirPath+"/NLSR%Y%m%d%H%M%S_%3N.log", // file name pattern
+ keywords::rotation_size = 128 * 1024 * 1024 , // rotation size, in characters
+ keywords::time_based_rotation = sinks::file::rotation_at_time_point(12, 0, 0),
+ keywords::auto_flush = true
));
-
+ //Set up where the rotated files will be stored
sink->locked_backend()->set_file_collector(sinks::file::make_collector(
keywords::target = logDirPath, // where to store rotated files
- keywords::max_size = 64 * 1024 * 1024 * 1024, // maximum total size of the stored files, in bytes
+ keywords::max_size = 16 * 1024 * 1024 * 1024, // maximum total size of the stored files, in bytes
keywords::min_free_space = 128 * 1024 * 1024 // minimum free space on the drive, in bytes
- ));
+ ));
- sink->set_formatter
- (
+ sink->set_formatter(
expr::format("%1%: %2%")
% getEpochTime()
% expr::smessage
- );
+ );
- // Add it to the core
+ // Add it to the core
logging::core::get()->add_sink(sink);
}
diff --git a/src/nlsr_logger.hpp b/src/nlsr_logger.hpp
index 119f172..78fba80 100644
--- a/src/nlsr_logger.hpp
+++ b/src/nlsr_logger.hpp
@@ -22,6 +22,7 @@
#include <boost/log/sinks/sync_frontend.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
+
namespace logging = boost::log;
namespace attrs = boost::log::attributes;
namespace src = boost::log::sources;
@@ -33,7 +34,6 @@
using namespace std;
-
class NlsrLogger
{
public:
@@ -43,7 +43,7 @@
void initNlsrLogger(std::string dirPath);
- boost::log::sources::logger& getLogger()
+ src::logger& getLogger()
{
return mLogger;
}
@@ -53,7 +53,7 @@
string getUserHomeDirectory();
private:
- boost::log::sources::logger mLogger;
+ src::logger mLogger;
};
#endif
diff --git a/src/nlsr_params.hpp b/src/nlsr_params.hpp
new file mode 100644
index 0000000..a5f11c5
--- /dev/null
+++ b/src/nlsr_params.hpp
@@ -0,0 +1,12 @@
+#ifndef NLSR_PARAMS_HPP
+#define NLSR_PARAMS_HPP
+
+class nlsrParams{
+
+
+
+
+
+};
+
+#endif