Use ndn-cxx logging facility
refs: #3949
Change-Id: I5d0931c3576c88e0c2fa52bdd0a716946400e0bc
diff --git a/.waf-tools/boost.py b/.waf-tools/boost.py
index 305945a..9b9395e 100644
--- a/.waf-tools/boost.py
+++ b/.waf-tools/boost.py
@@ -30,15 +30,15 @@
Options are generated, in order to specify the location of boost includes/libraries.
The `check_boost` configuration function allows to specify the used boost libraries.
-It can also provide default arguments to the --boost-static and --boost-mt command-line arguments.
+It can also provide default arguments to the --boost-mt command-line arguments.
Everything will be packaged together in a BOOST component that you can use.
When using MSVC, a lot of compilation flags need to match your BOOST build configuration:
- you may have to add /EHsc to your CXXFLAGS or define boost::throw_exception if BOOST_NO_EXCEPTIONS is defined.
Errors: C4530
- boost libraries will try to be smart and use the (pretty but often not useful) auto-linking feature of MSVC
- So before calling `conf.check_boost` you might want to disabling by adding:
- conf.env.DEFINES_BOOST += ['BOOST_ALL_NO_LIB']
+ So before calling `conf.check_boost` you might want to disabling by adding
+ conf.env.DEFINES_BOOST += ['BOOST_ALL_NO_LIB']
Errors:
- boost might also be compiled with /MT, which links the runtime statically.
If you have problems with redefined symbols,
@@ -52,24 +52,55 @@
import re
from waflib import Utils, Logs, Errors
from waflib.Configure import conf
+from waflib.TaskGen import feature, after_method
-BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib/x86_64-linux-gnu', '/usr/lib/i386-linux-gnu', '/usr/local/ndn/lib']
-BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include', '/usr/local/ndn/include']
+BOOST_LIBS = ['/usr/lib/x86_64-linux-gnu', '/usr/lib/i386-linux-gnu',
+ '/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib']
+BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include']
BOOST_VERSION_FILE = 'boost/version.hpp'
BOOST_VERSION_CODE = '''
#include <iostream>
#include <boost/version.hpp>
int main() { std::cout << BOOST_LIB_VERSION << ":" << BOOST_VERSION << std::endl; }
'''
-BOOST_SYSTEM_CODE = '''
+
+BOOST_ERROR_CODE = '''
#include <boost/system/error_code.hpp>
int main() { boost::system::error_code c; }
'''
+
+PTHREAD_CODE = '''
+#include <pthread.h>
+static void* f(void*) { return 0; }
+int main() {
+ pthread_t th;
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ pthread_create(&th, &attr, &f, 0);
+ pthread_join(th, 0);
+ pthread_cleanup_push(0, 0);
+ pthread_cleanup_pop(0);
+ pthread_attr_destroy(&attr);
+}
+'''
+
BOOST_THREAD_CODE = '''
#include <boost/thread.hpp>
int main() { boost::thread t; }
'''
+BOOST_LOG_CODE = '''
+#include <boost/log/trivial.hpp>
+#include <boost/log/utility/setup/console.hpp>
+#include <boost/log/utility/setup/common_attributes.hpp>
+int main() {
+ using namespace boost::log;
+ add_common_attributes();
+ add_console_log(std::clog, keywords::format = "%Message%");
+ BOOST_LOG_TRIVIAL(debug) << "log is working" << std::endl;
+}
+'''
+
# toolsets from {boost_dir}/tools/build/v2/tools/common.jam
PLATFORM = Utils.unversioned_sys_platform()
detect_intel = lambda env: (PLATFORM == 'win32') and 'iw' or 'il'
@@ -101,34 +132,37 @@
def options(opt):
opt = opt.add_option_group('Boost Options')
-
opt.add_option('--boost-includes', type='string',
default='', dest='boost_includes',
- help='''path to the directory where the boost includes are, e.g., /path/to/boost_1_55_0/stage/include''')
+ help='''path to the directory where the boost includes are,
+ e.g., /path/to/boost_1_55_0/stage/include''')
opt.add_option('--boost-libs', type='string',
default='', dest='boost_libs',
- help='''path to the directory where the boost libs are, e.g., /path/to/boost_1_55_0/stage/lib''')
- opt.add_option('--boost-static', action='store_true',
- default=False, dest='boost_static',
- help='link with static boost libraries (.lib/.a)')
+ help='''path to the directory where the boost libs are,
+ e.g., path/to/boost_1_55_0/stage/lib''')
opt.add_option('--boost-mt', action='store_true',
default=False, dest='boost_mt',
help='select multi-threaded libraries')
opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
- help='''select libraries with tags (dgsyp, d for debug), see doc Boost, Getting Started, chapter 6.1''')
+ help='''select libraries with tags (gd for debug, static is automatically added),
+ see doc Boost, Getting Started, chapter 6.1''')
opt.add_option('--boost-linkage_autodetect', action="store_true", dest='boost_linkage_autodetect',
help="auto-detect boost linkage options (don't get used to it / might break other stuff)")
opt.add_option('--boost-toolset', type='string',
default='', dest='boost_toolset',
- help='force a toolset e.g. msvc, vc90, gcc, mingw, mgw45 (default: auto)')
+ help='force a toolset e.g. msvc, vc90, \
+ gcc, mingw, mgw45 (default: auto)')
py_version = '%d%d' % (sys.version_info[0], sys.version_info[1])
opt.add_option('--boost-python', type='string',
default=py_version, dest='boost_python',
- help='select the lib python with this version (default: %s)' % py_version)
+ help='select the lib python with this version \
+ (default: %s)' % py_version)
@conf
def __boost_get_version_file(self, d):
+ if not d:
+ return None
dnode = self.root.find_dir(d)
if dnode:
return dnode.find_node(BOOST_VERSION_FILE)
@@ -141,18 +175,15 @@
if node:
try:
txt = node.read()
- except (OSError, IOError):
+ except EnvironmentError:
Logs.error("Could not read the file %r" % node.abspath())
else:
re_but1 = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.+)"', re.M)
m1 = re_but1.search(txt)
-
re_but2 = re.compile('^#define\\s+BOOST_VERSION\\s+(\\d+)', re.M)
m2 = re_but2.search(txt)
-
if m1 and m2:
return (m1.group(1), m2.group(1))
-
return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True).split(":")
@conf
@@ -160,7 +191,7 @@
includes = k and k[0] or kw.get('includes', None)
if includes and self.__boost_get_version_file(includes):
return includes
- for d in Utils.to_list(self.environ.get('INCLUDE', '')) + BOOST_INCLUDES:
+ for d in self.environ.get('INCLUDE', '').split(';') + BOOST_INCLUDES:
if self.__boost_get_version_file(d):
return d
if includes:
@@ -195,7 +226,9 @@
path = self.root.find_dir(libs)
files = path.ant_glob('*boost_*')
if not libs or not files:
- for d in Utils.to_list(self.environ.get('LIB', [])) + BOOST_LIBS:
+ for d in self.environ.get('LIB', '').split(';') + BOOST_LIBS:
+ if not d:
+ continue
path = self.root.find_dir(d)
if path:
files = path.ant_glob('*boost_*')
@@ -226,15 +259,10 @@
according to the parameters
'''
path, files = self.__boost_get_libs_path(**kw)
- t = []
- if kw.get('mt', False):
- t.append('mt')
- if kw.get('abi', None):
- t.append(kw['abi'])
- tags = t and '(-%s)+' % '-'.join(t) or ''
+ files = sorted(files, key=lambda f: (len(f.name), f.name), reverse=True)
toolset = self.boost_get_toolset(kw.get('toolset', ''))
- toolset_pat = '(-%s[0-9]{0,3})+' % toolset
- version = '(-%s)+' % self.env.BOOST_VERSION
+ toolset_pat = '(-%s[0-9]{0,3})' % toolset
+ version = '-%s' % self.env.BOOST_VERSION
def find_lib(re_lib, files):
for file in files:
@@ -248,28 +276,110 @@
name = name[3:]
return name[:name.rfind('.')]
- libs = []
- for lib in Utils.to_list(k and k[0] or kw.get('lib', None)):
- py = (lib == 'python') and '(-py%s)+' % kw['python'] or ''
- # Trying libraries, from most strict match to least one
- for pattern in ['boost_%s%s%s%s%s' % (lib, toolset_pat, tags, py, version),
- 'boost_%s%s%s%s' % (lib, tags, py, version),
- 'boost_%s%s%s' % (lib, tags, version),
- # Give up trying to find the right version
- 'boost_%s%s%s%s' % (lib, toolset_pat, tags, py),
- 'boost_%s%s%s' % (lib, tags, py),
- 'boost_%s%s' % (lib, tags)]:
- self.to_log('Trying pattern %s' % pattern)
- file = find_lib(re.compile(pattern), files)
- if file:
- libs.append(format_lib_name(file.name))
- break
- else:
- self.end_msg('lib %s not found in %s' % (lib, path.abspath()))
- self.fatal('The configuration failed')
+ def match_libs(lib_names, is_static):
+ libs = []
+ lib_names = Utils.to_list(lib_names)
+ if not lib_names:
+ return libs
+ t = []
+ if kw.get('mt', False):
+ t.append('-mt')
+ if kw.get('abi', None):
+ t.append('%s%s' % (is_static and '-s' or '-', kw['abi']))
+ elif is_static:
+ t.append('-s')
+ tags_pat = t and ''.join(t) or ''
+ ext = is_static and self.env.cxxstlib_PATTERN or self.env.cxxshlib_PATTERN
+ ext = ext.partition('%s')[2] # remove '%s' or 'lib%s' from PATTERN
- return path.abspath(), libs
+ for lib in lib_names:
+ if lib == 'python':
+ # for instance, with python='27',
+ # accepts '-py27', '-py2', '27' and '2'
+ # but will reject '-py3', '-py26', '26' and '3'
+ tags = '({0})?((-py{2})|(-py{1}(?=[^0-9]))|({2})|({1}(?=[^0-9]))|(?=[^0-9])(?!-py))'.format(tags_pat, kw['python'][0], kw['python'])
+ else:
+ tags = tags_pat
+ # Trying libraries, from most strict match to least one
+ for pattern in ['boost_%s%s%s%s%s$' % (lib, toolset_pat, tags, version, ext),
+ 'boost_%s%s%s%s$' % (lib, tags, version, ext),
+ # Give up trying to find the right version
+ 'boost_%s%s%s%s$' % (lib, toolset_pat, tags, ext),
+ 'boost_%s%s%s$' % (lib, tags, ext),
+ 'boost_%s%s$' % (lib, ext),
+ 'boost_%s' % lib]:
+ self.to_log('Trying pattern %s' % pattern)
+ file = find_lib(re.compile(pattern), files)
+ if file:
+ libs.append(format_lib_name(file.name))
+ break
+ else:
+ self.end_msg('lib %s not found in %s' % (lib, path.abspath()))
+ self.fatal('The configuration failed')
+ return libs
+ return path.abspath(), match_libs(kw.get('lib', None), False), match_libs(kw.get('stlib', None), True)
+
+@conf
+def _check_pthread_flag(self, *k, **kw):
+ '''
+ Computes which flags should be added to CXXFLAGS and LINKFLAGS to compile in multi-threading mode
+
+ Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
+ boost/thread.hpp will trigger a #error if -pthread isn't used:
+ boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
+ is not turned on. Please set the correct command line options for
+ threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
+
+ Based on _BOOST_PTHREAD_FLAG(): https://github.com/tsuna/boost.m4/blob/master/build-aux/boost.m4
+ '''
+
+ var = kw.get('uselib_store', 'BOOST')
+
+ self.start_msg('Checking the flags needed to use pthreads')
+
+ # The ordering *is* (sometimes) important. Some notes on the
+ # individual items follow:
+ # (none): in case threads are in libc; should be tried before -Kthread and
+ # other compiler flags to prevent continual compiler warnings
+ # -lpthreads: AIX (must check this before -lpthread)
+ # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+ # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+ # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+ # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
+ # -pthreads: Solaris/GCC
+ # -mthreads: MinGW32/GCC, Lynx/GCC
+ # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+ # doesn't hurt to check since this sometimes defines pthreads too;
+ # also defines -D_REENTRANT)
+ # ... -mt is also the pthreads flag for HP/aCC
+ # -lpthread: GNU Linux, etc.
+ # --thread-safe: KAI C++
+ if Utils.unversioned_sys_platform() == "sunos":
+ # On Solaris (at least, for some versions), libc contains stubbed
+ # (non-functional) versions of the pthreads routines, so link-based
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+ # a function called by this macro, so we could check for that, but
+ # who knows whether they'll stub that too in a future libc.) So,
+ # we'll just look for -pthreads and -lpthread first:
+ boost_pthread_flags = ["-pthreads", "-lpthread", "-mt", "-pthread"]
+ else:
+ boost_pthread_flags = ["", "-lpthreads", "-Kthread", "-kthread", "-llthread", "-pthread",
+ "-pthreads", "-mthreads", "-lpthread", "--thread-safe", "-mt"]
+
+ for boost_pthread_flag in boost_pthread_flags:
+ try:
+ self.env.stash()
+ self.env['CXXFLAGS_%s' % var] += [boost_pthread_flag]
+ self.env['LINKFLAGS_%s' % var] += [boost_pthread_flag]
+ self.check_cxx(code=PTHREAD_CODE, msg=None, use=var, execute=False)
+
+ self.end_msg(boost_pthread_flag)
+ return
+ except self.errors.ConfigurationError:
+ self.env.revert()
+ self.end_msg('None')
@conf
def check_boost(self, *k, **kw):
@@ -282,7 +392,10 @@
if not self.env['CXX']:
self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
- params = {'lib': k and k[0] or kw.get('lib', None)}
+ params = {
+ 'lib': k and k[0] or kw.get('lib', None),
+ 'stlib': kw.get('stlib', None)
+ }
for key, value in self.options.__dict__.items():
if not key.startswith('boost_'):
continue
@@ -297,42 +410,53 @@
self.env.BOOST_VERSION = versions[0]
self.env.BOOST_VERSION_NUMBER = int(versions[1])
self.end_msg("%d.%d.%d" % (int(versions[1]) / 100000,
- int(versions[1]) / 100 % 1000,
- int(versions[1]) % 100))
+ int(versions[1]) / 100 % 1000,
+ int(versions[1]) % 100))
if Logs.verbose:
Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
- if not params['lib']:
+ if not params['lib'] and not params['stlib']:
return
+ if 'static' in kw or 'static' in params:
+ Logs.warn('boost: static parameter is deprecated, use stlib instead.')
self.start_msg('Checking boost libs')
- suffix = params.get('static', None) and 'ST' or ''
- path, libs = self.boost_get_libs(**params)
- self.env['%sLIBPATH_%s' % (suffix, var)] = [path]
- self.env['%sLIB_%s' % (suffix, var)] = libs
+ path, libs, stlibs = self.boost_get_libs(**params)
+ self.env['LIBPATH_%s' % var] = [path]
+ self.env['STLIBPATH_%s' % var] = [path]
+ self.env['LIB_%s' % var] = libs
+ self.env['STLIB_%s' % var] = stlibs
self.end_msg('ok')
if Logs.verbose:
Logs.pprint('CYAN', ' path : %s' % path)
- Logs.pprint('CYAN', ' libs : %s' % libs)
+ Logs.pprint('CYAN', ' shared libs : %s' % libs)
+ Logs.pprint('CYAN', ' static libs : %s' % stlibs)
+ def has_shlib(lib):
+ return params['lib'] and lib in params['lib']
+ def has_stlib(lib):
+ return params['stlib'] and lib in params['stlib']
+ def has_lib(lib):
+ return has_shlib(lib) or has_stlib(lib)
+ if has_lib('thread'):
+ # not inside try_link to make check visible in the output
+ self._check_pthread_flag(k, kw)
def try_link():
- if 'system' in params['lib']:
- self.check_cxx(
- fragment=BOOST_SYSTEM_CODE,
- use=var,
- execute=False,
- )
- if 'thread' in params['lib']:
- self.check_cxx(
- fragment=BOOST_THREAD_CODE,
- use=var,
- execute=False,
- )
+ if has_lib('system'):
+ self.check_cxx(fragment=BOOST_ERROR_CODE, use=var, execute=False)
+ if has_lib('thread'):
+ self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False)
+ if has_lib('log'):
+ if not has_lib('thread'):
+ self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
+ if has_shlib('log'):
+ self.env['DEFINES_%s' % var] += ['BOOST_LOG_DYN_LINK']
+ self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)
if params.get('linkage_autodetect', False):
self.start_msg("Attempting to detect boost linkage flags")
toolset = self.boost_get_toolset(kw.get('toolset', ''))
- if toolset in ['vc']:
+ if toolset in ('vc',):
# disable auto-linking feature, causing error LNK1181
# because the code wants to be linked against
self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']
@@ -356,14 +480,14 @@
try:
try_link()
self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
- e = None
+ exc = None
break
- except Errors.ConfigurationError as exc:
+ except Errors.ConfigurationError as e:
self.env.revert()
- e = exc
+ exc = e
- if e is not None:
- self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=e)
+ if exc is not None:
+ self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=exc)
self.fatal('The configuration failed')
else:
self.end_msg("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
@@ -376,3 +500,19 @@
self.end_msg("Could not link against boost libraries using supplied options")
self.fatal('The configuration failed')
self.end_msg('ok')
+
+
+@feature('cxx')
+@after_method('apply_link')
+def install_boost(self):
+ if install_boost.done or not Utils.is_win32 or not self.bld.cmd.startswith('install'):
+ return
+ install_boost.done = True
+ inst_to = getattr(self, 'install_path', '${BINDIR}')
+ for lib in self.env.LIB_BOOST:
+ try:
+ file = self.bld.find_file(self.env.cxxshlib_PATTERN % lib, self.env.LIBPATH_BOOST)
+ self.bld.install_files(inst_to, self.bld.root.find_node(file))
+ except:
+ continue
+install_boost.done = False
diff --git a/COPYING.md b/COPYING.md
index 3ff9a6f..b5f29be 100644
--- a/COPYING.md
+++ b/COPYING.md
@@ -9,9 +9,6 @@
- Boost libraries are licensed under the conditions of
[Boost Software License 1.0](http://www.boost.org/users/license.html)
-- log4cxx is licensed under the conditions of
- [Apache License, Version 2.0](https://logging.apache.org/log4cxx/license.html)
-
- ndn-cxx is licensed under the conditions of
[LGPL 3.0](https://github.com/named-data/ndn-cxx/blob/master/COPYING.md)
diff --git a/docs/GETTING-STARTED.rst b/docs/GETTING-STARTED.rst
index 0dbfafd..f2bd2d9 100644
--- a/docs/GETTING-STARTED.rst
+++ b/docs/GETTING-STARTED.rst
@@ -53,8 +53,26 @@
nlsr -f /usr/local/etc/ndn/nlsr.conf
-To run NLSR as daemon, use the ``-d`` flag:
+Logging
+-------
+
+NLSR uses the ndn-cxx logging facility. All levels listed below the selected log-level
+value are enabled.
::
- nlsr -d
+ Valid values:
+
+ TRACE trace messages (most verbose)
+ DEBUG debugging messages
+ INFO informational messages
+ WARN warning messages
+ ERROR error messages
+ FATAL fatal (will be logged unconditionally)
+
+To obtain logs for NLSR, set the NDN_LOG environment variable with the correct prefix and
+log-level settings. For example, running the command `export NDN_LOG=nlsr.*=TRACE && nlsr`
+will display all log messages in NLSR with a DEBUG level or below. If the user is presented
+with an error message `User does not have read and write permission on the directory` it can
+be circumvented by running the application with sudo: `sudo env NDN_LOG=nlsr.*=DEBUG nlsr`.
+Use `man ndn-log` for more detailed instructions.
diff --git a/docs/INSTALL.rst b/docs/INSTALL.rst
index f54163a..947d067 100644
--- a/docs/INSTALL.rst
+++ b/docs/INSTALL.rst
@@ -18,20 +18,6 @@
https://github.com/named-data/ChronoSync#build
-- log4cxx library
-
- On Ubuntu Linux:
-
- ::
-
- sudo apt-get install liblog4cxx10-dev
-
- On OS X with MacPorts:
-
- ::
-
- sudo port install log4cxx
-
Build
-----
diff --git a/docs/ROUTER-CONFIG.rst b/docs/ROUTER-CONFIG.rst
index fd08cb6..277d7a3 100644
--- a/docs/ROUTER-CONFIG.rst
+++ b/docs/ROUTER-CONFIG.rst
@@ -83,11 +83,7 @@
; InterestLifetime (in seconds) for LSA fetching
lsa-interest-lifetime 4 ; default value 4. Valid values 1-60
- ; log-level is to set the levels of log for NLSR
- log-level INFO ; default value INFO, valid value DEBUG, INFO
- log-dir /var/log/nlsr/
seq-dir /var/lib/nlsr/
- ; log4cxx-conf /path/to/log4cxx-conf
}
; the neighbors section contains the configuration for router's neighbors and hello's behavior
@@ -183,28 +179,17 @@
prefix /ndn/news/memphis/politics/lutherking
}
-
-NLSR will have the following error if ``log-dir`` does not exist:
-
-::
-
- Provided log directory </var/log/nlsr/> does not exist
- Error in configuration file processing! Exiting from NLSR
-
-By default ``/var/log/nlsr/`` is set to be NLSR's log directory and ``/var/lib/nlsr/`` is set to be
-NLSR's sequence file directory. They do not exist and will need to be created.
-Also, since these are system directories it will require the user to run NLSR as root.
-If one does not have permission to write to the specified directory,
-then NLSR will produce the following error:
+By default NLSR's sequence file directory is set to ``/var/lib/nlsr/``. User must create this
+directory before starting NLSR. Since this is a system directory, NLSR must either be executed
+as root, or NLSR can be run as user "nlsr" after configuring the filesystem to grant "nlsr"
+read and write permissions. If user lacks permissions, the following error will occur:
::
User does not have read and write permission on the directory
Error in configuration file processing! Exiting from NLSR
-To avoid this, the directories can be set in a user owned directory.
-The directories for log and sequence file can be same.
-For example:
+To avoid this, the directory can be set in a user-owned directory. For example:
::
@@ -212,7 +197,6 @@
{
...
- log-dir /home/username/nlsr/log ; path for log directory (Absolute path)
seq-dir /home/username/nlsr/log ; path for sequence directory (Absolute path)
}
diff --git a/docs/manpages/nlsr.rst b/docs/manpages/nlsr.rst
index 3dd0927..c047bf2 100644
--- a/docs/manpages/nlsr.rst
+++ b/docs/manpages/nlsr.rst
@@ -12,16 +12,12 @@
Description
-----------
-``nlsr`` is a daemon that implements routing protocol in NDN to populates NDN's Routing
+``nlsr`` is a process that implements routing protocol in NDN to populate NDN's Routing
Information Base.
Options:
--------
-
-``-d``
- Run in daemon mode
-
``-f <FILE>``
Specify configuration file name (default: ``./nlsr.conf``)
@@ -34,14 +30,8 @@
Examples
--------
-To run NLSR daemon and use a configuration file from the ``/path/to`` directory.
+To run NLSR and use a configuration file from the ``/path/to`` directory.
::
nlsr -f /path/to/nlsr.conf
-
-To run NLSR as daemon, use the ``-d`` flag:
-
-::
-
- nlsr -d
diff --git a/log4cxx.properties.sample.in b/log4cxx.properties.sample.in
deleted file mode 100644
index 14e83a8..0000000
--- a/log4cxx.properties.sample.in
+++ /dev/null
@@ -1,11 +0,0 @@
-log4j.rootLogger=DEBUG, Rolling
-
-log4j.appender.Rolling=org.apache.log4j.rolling.RollingFileAppender
-log4j.appender.Rolling.File=/tmp/testnlsrproperties.log
-log4j.appender.Rolling.MaxSize=1MB
-log4j.appender.Rolling.MaxBackupIndex=10
-
-log4j.appender.Rolling.layout=PatternLayout
-log4j.appender.Rolling.layout.ContextPrinting=enabled
-log4j.appender.Rolling.layout.DateFormat=ISO8601
-log4j.appender.Rolling.layout.ConversionPattern=%date{yyyyMMddHHmmssSSS} %p: [%c] %m%n
\ No newline at end of file
diff --git a/nlsr.conf b/nlsr.conf
index 378f63c..d5421ed 100644
--- a/nlsr.conf
+++ b/nlsr.conf
@@ -19,24 +19,7 @@
; InterestLifetime (in seconds) for LSA fetching
lsa-interest-lifetime 4 ; default value 4. Valid values 1-60
- ; log-level is used to set the logging level for NLSR.
- ; All debugging levels listed above the selected value are enabled.
- ;
- ; Valid values:
- ;
- ; NONE ; no messages
- ; ERROR ; error messages
- ; WARN ; warning messages
- ; INFO ; informational messages (default)
- ; DEBUG ; debugging messages
- ; TRACE ; trace messages (most verbose)
- ; ALL ; all messages
-
- log-level INFO
-
- log-dir /var/log/nlsr/ ; path for log directory (Absolute path)
- seq-dir /var/lib/nlsr/ ; path for sequence directory (Absolute path)
- ;log4cxx-conf /path/to/log4cxx-conf ; path for log4cxx configuration file (Absolute path)
+ seq-dir /var/lib/nlsr ; path for sequence directory (Absolute path)
}
; the neighbor's section contains the configuration for router's neighbors and hellos behavior
diff --git a/src/adjacency-list.cpp b/src/adjacency-list.cpp
index 9d02d7e..c41917c 100644
--- a/src/adjacency-list.cpp
+++ b/src/adjacency-list.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -29,7 +29,7 @@
namespace nlsr {
-INIT_LOGGER("AdjacencyList");
+INIT_LOGGER(AdjacencyList);
AdjacencyList::AdjacencyList()
{
diff --git a/src/adjacent.cpp b/src/adjacent.cpp
index 0476878..183dcef 100644
--- a/src/adjacent.cpp
+++ b/src/adjacent.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -28,7 +28,7 @@
namespace nlsr {
-INIT_LOGGER("Adjacent");
+INIT_LOGGER(Adjacent);
const float Adjacent::DEFAULT_LINK_COST = 10.0;
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index 047b5d2..01e4bd3 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -28,7 +28,7 @@
namespace nlsr {
-INIT_LOGGER("SyncLogicHandler");
+INIT_LOGGER(SyncLogicHandler);
const std::string NLSR_COMPONENT = "NLSR";
const std::string LSA_COMPONENT = "LSA";
diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp
index d13b415..e93ef35 100644
--- a/src/conf-file-processor.cpp
+++ b/src/conf-file-processor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -287,52 +287,6 @@
return false;
}
- // log-level
- std::string logLevel = section.get<std::string>("log-level", "INFO");
-
- if (isValidLogLevel(logLevel)) {
- m_nlsr.getConfParameter().setLogLevel(logLevel);
- }
- else {
- std::cerr << "Invalid value for log-level ";
- std::cerr << "Valid values: ALL, TRACE, DEBUG, INFO, WARN, ERROR, NONE" << std::endl;
- return false;
- }
-
- try {
- std::string logDir = section.get<std::string>("log-dir");
- if (boost::filesystem::exists(logDir)) {
- if (boost::filesystem::is_directory(logDir)) {
- std::string testFileName=logDir+"/test.log";
- std::ofstream testOutFile;
- testOutFile.open(testFileName.c_str());
- if (testOutFile.is_open() && testOutFile.good()) {
- m_nlsr.getConfParameter().setLogDir(logDir);
- }
- else {
- std::cerr << "User does not have read and write permission on the directory";
- std::cerr << std::endl;
- return false;
- }
- testOutFile.close();
- remove(testFileName.c_str());
- }
- else {
- std::cerr << "Provided path is not a directory" << std::endl;
- return false;
- }
- }
- else {
- std::cerr << "Provided log directory <" << logDir << "> does not exist" << std::endl;
- return false;
- }
- }
- catch (const std::exception& ex) {
- std::cerr << "You must configure log directory" << std::endl;
- std::cerr << ex.what() << std::endl;
- return false;
- }
-
try {
std::string seqDir = section.get<std::string>("seq-dir");
if (boost::filesystem::exists(seqDir)) {
@@ -367,28 +321,6 @@
return false;
}
- try {
- std::string log4cxxPath = section.get<std::string>("log4cxx-conf");
-
- if (log4cxxPath == "") {
- std::cerr << "No value provided for log4cxx-conf" << std::endl;
- return false;
- }
-
- if (boost::filesystem::exists(log4cxxPath)) {
- m_nlsr.getConfParameter().setLog4CxxConfPath(log4cxxPath);
- }
- else {
- std::cerr << "Provided path for log4cxx-conf <" << log4cxxPath
- << "> does not exist" << std::endl;
-
- return false;
- }
- }
- catch (const std::exception& ex) {
- // Variable is optional so default configuration will be used; continue processing file
- }
-
return true;
}
diff --git a/src/conf-file-processor.hpp b/src/conf-file-processor.hpp
index d3e91c9..4218657 100644
--- a/src/conf-file-processor.hpp
+++ b/src/conf-file-processor.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -83,7 +83,7 @@
bool
processSection(const std::string& sectionName, const ConfigSection& section);
- /*! \brief Parse general options, including router name, logging directory, LSA refresh.
+ /*! \brief Parse general options, including router name, LSA refresh.
*/
bool
processConfSectionGeneral(const ConfigSection& section);
diff --git a/src/conf-parameter.cpp b/src/conf-parameter.cpp
index 05a96dd..f0d41cb 100644
--- a/src/conf-parameter.cpp
+++ b/src/conf-parameter.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -26,7 +26,7 @@
namespace nlsr {
-INIT_LOGGER("ConfParameter");
+INIT_LOGGER(ConfParameter);
void
ConfParameter::writeLog()
@@ -51,7 +51,6 @@
for (auto const& value: m_corTheta) {
NLSR_LOG_INFO("Hyp Angle " << i++ << ": "<< value);
}
- NLSR_LOG_INFO("Log Directory: " << m_logDir);
NLSR_LOG_INFO("Seq Directory: " << m_seqFileDir);
// Event Intervals
diff --git a/src/conf-parameter.hpp b/src/conf-parameter.hpp
index 00aa06a..ee22764 100644
--- a/src/conf-parameter.hpp
+++ b/src/conf-parameter.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -136,7 +136,6 @@
, m_hyperbolicState(HYPERBOLIC_STATE_OFF)
, m_corR(0)
, m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
- , m_isLog4cxxConfAvailable(false)
{
}
@@ -410,18 +409,6 @@
}
void
- setLogDir(const std::string& logDir)
- {
- m_logDir = logDir;
- }
-
- const std::string&
- getLogDir() const
- {
- return m_logDir;
- }
-
- void
setSeqFileDir(const std::string& ssfd)
{
m_seqFileDir = ssfd;
@@ -433,27 +420,6 @@
return m_seqFileDir;
}
- bool
- isLog4CxxConfAvailable() const
- {
- return m_isLog4cxxConfAvailable;
- }
-
- void
- setLog4CxxConfPath(const std::string& path)
- {
- m_log4CxxConfPath = path;
- m_isLog4cxxConfAvailable = true;
- }
-
- const std::string&
- getLog4CxxConfPath() const
- {
- return m_log4CxxConfPath;
- }
-
- /*! \brief Dump the current state of all attributes to the log.
- */
void
writeLog();
@@ -492,11 +458,8 @@
uint32_t m_maxFacesPerPrefix;
- std::string m_logDir;
std::string m_seqFileDir;
- bool m_isLog4cxxConfAvailable;
- std::string m_log4CxxConfPath;
};
} // namespace nlsr
diff --git a/src/hello-protocol.cpp b/src/hello-protocol.cpp
index fbb4f5b..0c2d2d3 100644
--- a/src/hello-protocol.cpp
+++ b/src/hello-protocol.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -27,7 +27,7 @@
namespace nlsr {
-INIT_LOGGER("HelloProtocol");
+INIT_LOGGER(HelloProtocol);
const std::string HelloProtocol::INFO_COMPONENT = "INFO";
const std::string HelloProtocol::NLSR_COMPONENT = "NLSR";
diff --git a/src/logger.cpp b/src/logger.cpp
deleted file mode 100644
index c51cd93..0000000
--- a/src/logger.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, The University of Memphis,
- * Regents of the University of California
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-#include "logger.hpp"
-
-#include <log4cxx/logger.h>
-#include <log4cxx/basicconfigurator.h>
-#include <log4cxx/xml/domconfigurator.h>
-#include <log4cxx/propertyconfigurator.h>
-#include <log4cxx/patternlayout.h>
-#include <log4cxx/level.h>
-#include <log4cxx/helpers/exception.h>
-#include <log4cxx/rollingfileappender.h>
-
-#include <boost/algorithm/string.hpp>
-#include <boost/filesystem.hpp>
-
-void
-INIT_LOG4CXX(const std::string& log4cxxConfPath)
-{
- if (boost::filesystem::path(log4cxxConfPath).extension().string() == ".xml") {
- log4cxx::xml::DOMConfigurator::configure(log4cxxConfPath);
- }
- else {
- log4cxx::PropertyConfigurator::configure(log4cxxConfPath);
- }
-}
-
-void
-INIT_LOGGERS(const std::string& logDir, const std::string& logLevel)
-{
- static bool configured = false;
-
- if (configured) {
- return;
- }
-
- log4cxx::PatternLayoutPtr
- layout(new log4cxx::PatternLayout("%date{%s}.%date{SSS} %p: [%c] %m%n"));
-
- log4cxx::RollingFileAppender* rollingFileAppender =
- new log4cxx::RollingFileAppender(layout, logDir+"/nlsr.log", true);
-
- rollingFileAppender->setMaxFileSize("10MB");
- rollingFileAppender->setMaxBackupIndex(10);
-
- log4cxx::helpers::Pool p;
- rollingFileAppender->activateOptions(p);
-
- log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(rollingFileAppender));
-
- if (boost::iequals(logLevel, "none")) {
- log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getOff());
- }
- else {
- log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::toLevel(logLevel));
- }
-
- configured = true;
-}
-
-bool
-isValidLogLevel(const std::string& logLevel)
-{
- return boost::iequals(logLevel, "all") || boost::iequals(logLevel, "trace") ||
- boost::iequals(logLevel, "debug") || boost::iequals(logLevel, "info") ||
- boost::iequals(logLevel, "warn") || boost::iequals(logLevel, "error") ||
- boost::iequals(logLevel, "none");
-}
diff --git a/src/logger.hpp b/src/logger.hpp
index 2236266..7925107 100644
--- a/src/logger.hpp
+++ b/src/logger.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -30,36 +30,15 @@
#ifndef NLSR_LOGGER_HPP
#define NLSR_LOGGER_HPP
-#include <log4cxx/logger.h>
+#include <ndn-cxx/util/logger.hpp>
-#define INIT_LOGGER(name) \
- static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger(name)
+#define INIT_LOGGER(name) NDN_LOG_INIT(nlsr.name)
-#define NLSR_LOG_TRACE(x) \
- LOG4CXX_TRACE(staticModuleLogger, x)
-
-#define NLSR_LOG_DEBUG(x) \
- LOG4CXX_DEBUG(staticModuleLogger, x)
-
-#define NLSR_LOG_INFO(x) \
- LOG4CXX_INFO(staticModuleLogger, x)
-
-#define NLSR_LOG_WARN(x) \
- LOG4CXX_WARN(staticModuleLogger, x)
-
-#define NLSR_LOG_ERROR(x) \
- LOG4CXX_ERROR(staticModuleLogger, x)
-
-#define NLSR_LOG_FATAL(x) \
- LOG4CXX_FATAL(staticModuleLogger, x);
-
-void
-INIT_LOGGERS(const std::string& logDir, const std::string& logLevel);
-
-void
-INIT_LOG4CXX(const std::string& log4cxxConfPath);
-
-bool
-isValidLogLevel(const std::string& logLevel);
+#define NLSR_LOG_TRACE(x) NDN_LOG_TRACE(x)
+#define NLSR_LOG_DEBUG(x) NDN_LOG_DEBUG(x)
+#define NLSR_LOG_INFO(x) NDN_LOG_INFO(x)
+#define NLSR_LOG_WARN(x) NDN_LOG_WARN(x)
+#define NLSR_LOG_ERROR(x) NDN_LOG_ERROR(x)
+#define NLSR_LOG_FATAL(x) NDN_LOG_FATAL(x)
#endif // NLSR_LOGGER_HPP
diff --git a/src/lsa.cpp b/src/lsa.cpp
index 91f6a7a..84bd5fe 100644
--- a/src/lsa.cpp
+++ b/src/lsa.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -35,7 +35,7 @@
namespace nlsr {
-INIT_LOGGER("Lsa");
+INIT_LOGGER(Lsa);
std::string
Lsa::getData() const
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index 6df2346..536d154 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -31,7 +31,7 @@
namespace nlsr {
-INIT_LOGGER("Lsdb");
+INIT_LOGGER(Lsdb);
class LsaContentPublisher : public SegmentPublisher<ndn::Face>
{
@@ -1096,7 +1096,8 @@
lsaIncrementSignal(Statistics::PacketType::RCV_NAME_LSA_INTEREST);
NLSR_LOG_DEBUG("nameLsa interest " << interest << " received");
NameLsa* nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
- if (nameLsa != 0) {
+ if (nameLsa != nullptr) {
+ NLSR_LOG_TRACE("Verifying SeqNo for NameLsa is same as requested.");
if (nameLsa->getLsSeqNo() == seqNo) {
std::string content = nameLsa->serialize();
putLsaData(interest,content);
@@ -1130,7 +1131,8 @@
lsaIncrementSignal(Statistics::PacketType::RCV_ADJ_LSA_INTEREST);
NLSR_LOG_DEBUG("AdjLsa interest " << interest << " received");
AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
- if (adjLsa != 0) {
+ if (adjLsa != nullptr) {
+ NLSR_LOG_TRACE("Verifying SeqNo for AdjLsa is same as requested.");
if (adjLsa->getLsSeqNo() == seqNo) {
std::string content = adjLsa->serialize();
putLsaData(interest,content);
@@ -1164,7 +1166,8 @@
lsaIncrementSignal(Statistics::PacketType::RCV_COORD_LSA_INTEREST);
NLSR_LOG_DEBUG("CoordinateLsa interest " << interest << " received");
CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
- if (corLsa != 0) {
+ if (corLsa != nullptr) {
+ NLSR_LOG_TRACE("Verifying SeqNo for CoordinateLsa is same as requested.");
if (corLsa->getLsSeqNo() == seqNo) {
std::string content = corLsa->serialize();
putLsaData(interest,content);
diff --git a/src/main.cpp b/src/main.cpp
index c01f8d4..eb336de 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -30,7 +30,6 @@
std::string programName(argv[0]);
std::string configFileName = "nlsr.conf";
- bool isDaemonProcess = false;
int32_t opt;
while ((opt = getopt(argc, argv, "df:hV")) != -1) {
@@ -38,9 +37,6 @@
case 'f':
configFileName = optarg;
break;
- case 'd':
- isDaemonProcess = true;
- break;
case 'V':
std::cout << NLSR_VERSION_BUILD_STRING << std::endl;
return EXIT_SUCCESS;
@@ -52,7 +48,7 @@
}
}
- NlsrRunner runner(configFileName, isDaemonProcess);
+ NlsrRunner runner(configFileName);
try {
runner.run();
diff --git a/src/name-prefix-list.cpp b/src/name-prefix-list.cpp
index 486e350..26f54d4 100644
--- a/src/name-prefix-list.cpp
+++ b/src/name-prefix-list.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -21,18 +21,13 @@
#include "name-prefix-list.hpp"
#include "common.hpp"
-#include "logger.hpp"
#include <iostream>
#include <algorithm>
namespace nlsr {
-INIT_LOGGER("NamePrefixList");
-
-NamePrefixList::NamePrefixList()
-{
-}
+NamePrefixList::NamePrefixList() = default;
NamePrefixList::NamePrefixList(const std::initializer_list<ndn::Name>& names)
{
diff --git a/src/nlsr-runner.cpp b/src/nlsr-runner.cpp
index 652139f..7f27f45 100644
--- a/src/nlsr-runner.cpp
+++ b/src/nlsr-runner.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -20,21 +20,19 @@
**/
#include "nlsr-runner.hpp"
-
#include "conf-file-processor.hpp"
#include "logger.hpp"
namespace nlsr {
-INIT_LOGGER("NlsrRunner");
+INIT_LOGGER(NlsrRunner);
-NlsrRunner::NlsrRunner(std::string& configFileName, bool isDaemonProcess)
+NlsrRunner::NlsrRunner(std::string& configFileName)
: m_scheduler(m_ioService)
, m_face(m_ioService)
, m_nlsr(m_ioService, m_scheduler, m_face, m_keyChain)
{
m_nlsr.setConfFileName(configFileName);
- m_nlsr.setIsDaemonProcess(isDaemonProcess);
}
void
@@ -46,17 +44,6 @@
BOOST_THROW_EXCEPTION(Error("Error in configuration file processing! Exiting from NLSR"));
}
- if (m_nlsr.getConfParameter().isLog4CxxConfAvailable()) {
- INIT_LOG4CXX(m_nlsr.getConfParameter().getLog4CxxConfPath());
- }
- else {
- INIT_LOGGERS(m_nlsr.getConfParameter().getLogDir(), m_nlsr.getConfParameter().getLogLevel());
- }
-
- if (m_nlsr.getIsSetDaemonProcess()) {
- m_nlsr.daemonize();
- }
-
/** Because URI canonization needs to occur before initialization,
we have to pass initialize as the finally() in neighbor
canonization.
@@ -86,7 +73,6 @@
{
std::cout << "Usage: " << programName << " [OPTIONS...]" << std::endl;
std::cout << " NDN routing...." << std::endl;
- std::cout << " -d Run in daemon mode" << std::endl;
std::cout << " -f <FILE> Specify configuration file name" << std::endl;
std::cout << " -V Display version information" << std::endl;
std::cout << " -h Display this help message" << std::endl;
diff --git a/src/nlsr-runner.hpp b/src/nlsr-runner.hpp
index 7d4505e..76d0456 100644
--- a/src/nlsr-runner.hpp
+++ b/src/nlsr-runner.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -36,11 +36,11 @@
*
* As its name suggests, this class is responsible for running
* NLSR. It creates an nlsr::ConfFileProcessor to read a configuration
- * file and uses that to configure and then start an NLSR process. It
- * also initializes loggers and optionally daemonizes the NLSR
- * process. This class only exists to provide this functionality, and
- * there is no special reliance of NLSR on this class.
+ * file and uses that to configure and then start an NLSR process.
+ * This class only exists to provide this functionality, and there is
+ * no special reliance of NLSR on this class.
*/
+
class NlsrRunner
{
public:
@@ -54,7 +54,8 @@
}
};
- NlsrRunner(std::string& configFileName, bool isDaemonProcess);
+ explicit
+ NlsrRunner(std::string& configFileName);
/*! \brief Instantiate, configure, and start the NLSR process.
*
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index ab4a073..583fdcb 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -34,7 +34,7 @@
namespace nlsr {
-INIT_LOGGER("nlsr");
+INIT_LOGGER(Nlsr);
const ndn::Name Nlsr::LOCALHOST_PREFIX = ndn::Name("/localhost/nlsr");
@@ -45,7 +45,6 @@
, m_confParam()
, m_adjacencyList()
, m_namePrefixList()
- , m_isDaemonProcess(false)
, m_configFileName("nlsr.conf")
, m_nlsrLsdb(*this, scheduler)
, m_adjBuildCount(0)
@@ -149,32 +148,6 @@
}
void
-Nlsr::daemonize()
-{
- pid_t process_id = 0;
- pid_t sid = 0;
- process_id = fork();
- if (process_id < 0){
- std::cerr << "Daemonization failed!" << std::endl;
- BOOST_THROW_EXCEPTION(Error("Error: Daemonization process- fork failed!"));
- }
- if (process_id > 0) {
- NLSR_LOG_DEBUG("Process daemonized. Process id: " << process_id);
- exit(0);
- }
-
- umask(0);
- sid = setsid();
- if(sid < 0) {
- BOOST_THROW_EXCEPTION(Error("Error: Daemonization process- setting id failed!"));
- }
-
- if (chdir("/") < 0) {
- BOOST_THROW_EXCEPTION(Error("Error: Daemonization process-chdir failed!"));
- }
-}
-
-void
Nlsr::canonizeContinuation(std::list<Adjacent>::iterator iterator,
std::function<void(void)> finally)
{
diff --git a/src/nlsr.hpp b/src/nlsr.hpp
index 10999d2..0a29184 100644
--- a/src/nlsr.hpp
+++ b/src/nlsr.hpp
@@ -117,18 +117,6 @@
m_configFileName = fileName;
}
- bool
- getIsSetDaemonProcess()
- {
- return m_isDaemonProcess;
- }
-
- void
- setIsDaemonProcess(bool value)
- {
- m_isDaemonProcess = value;
- }
-
ConfParameter&
getConfParameter()
{
@@ -364,9 +352,6 @@
void
setStrategies();
- void
- daemonize();
-
uint32_t
getFirstHelloInterval() const
{
@@ -479,7 +464,6 @@
ConfParameter m_confParam;
AdjacencyList m_adjacencyList;
NamePrefixList m_namePrefixList;
- bool m_isDaemonProcess;
std::string m_configFileName;
Lsdb m_nlsrLsdb;
int64_t m_adjBuildCount;
diff --git a/src/publisher/dataset-interest-handler.cpp b/src/publisher/dataset-interest-handler.cpp
index efd76f8..15a1eea 100644
--- a/src/publisher/dataset-interest-handler.cpp
+++ b/src/publisher/dataset-interest-handler.cpp
@@ -29,7 +29,7 @@
namespace nlsr {
-INIT_LOGGER("DatasetInterestHandler");
+INIT_LOGGER(DatasetInterestHandler);
const ndn::PartialName ADJACENCIES_DATASET = ndn::PartialName("lsdb/adjacencies");
const ndn::PartialName COORDINATES_DATASET = ndn::PartialName("lsdb/coordinates");
diff --git a/src/route/face-map.cpp b/src/route/face-map.cpp
index 95a37bf..52026d0 100644
--- a/src/route/face-map.cpp
+++ b/src/route/face-map.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -29,7 +29,7 @@
namespace nlsr {
-INIT_LOGGER("FaceMap");
+INIT_LOGGER(route.FaceMap);
void
FaceMap::writeLog()
diff --git a/src/route/fib-entry.cpp b/src/route/fib-entry.cpp
index 4a4498a..a3186b3 100644
--- a/src/route/fib-entry.cpp
+++ b/src/route/fib-entry.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -23,7 +23,7 @@
namespace nlsr {
-INIT_LOGGER("FibEntry");
+INIT_LOGGER(route.FibEntry);
void
FibEntry::writeLog()
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index c2ba20d..d472920 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -31,7 +31,7 @@
namespace nlsr {
-INIT_LOGGER("Fib");
+INIT_LOGGER(route.Fib);
const uint64_t Fib::GRACE_PERIOD = 10;
diff --git a/src/route/map.cpp b/src/route/map.cpp
index 82f73b0..a3ca7d1 100644
--- a/src/route/map.cpp
+++ b/src/route/map.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -25,12 +25,9 @@
#include "lsdb.hpp"
#include "logger.hpp"
-#include <iostream>
-#include <list>
-
namespace nlsr {
-INIT_LOGGER("Map");
+INIT_LOGGER(route.Map);
void
Map::addEntry(const ndn::Name& rtrName)
diff --git a/src/route/name-prefix-table-entry.cpp b/src/route/name-prefix-table-entry.cpp
index 2403003..ac4c3ec 100644
--- a/src/route/name-prefix-table-entry.cpp
+++ b/src/route/name-prefix-table-entry.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -27,7 +27,7 @@
namespace nlsr {
-INIT_LOGGER("NamePrefixTableEntry");
+INIT_LOGGER(route.NamePrefixTableEntry);
void
NamePrefixTableEntry::generateNhlfromRteList()
diff --git a/src/route/name-prefix-table.cpp b/src/route/name-prefix-table.cpp
index 4496f6c..d2e8527 100644
--- a/src/route/name-prefix-table.cpp
+++ b/src/route/name-prefix-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -31,7 +31,7 @@
namespace nlsr {
-INIT_LOGGER("NamePrefixTable");
+INIT_LOGGER(route.NamePrefixTable);
NamePrefixTable::NamePrefixTable(Nlsr& nlsr,
std::unique_ptr<AfterRoutingChange>& afterRoutingChangeSignal)
diff --git a/src/route/nexthop-list.cpp b/src/route/nexthop-list.cpp
index a0a585a..698e06a 100644
--- a/src/route/nexthop-list.cpp
+++ b/src/route/nexthop-list.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -26,7 +26,7 @@
namespace nlsr {
-INIT_LOGGER("NexthopList");
+INIT_LOGGER(route.NexthopList);
static bool
nexthopAddCompare(const NextHop& nh1, const NextHop& nh2)
diff --git a/src/route/routing-table-calculator.cpp b/src/route/routing-table-calculator.cpp
index c7b7d08..a35df65 100644
--- a/src/route/routing-table-calculator.cpp
+++ b/src/route/routing-table-calculator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -33,7 +33,7 @@
namespace nlsr {
-INIT_LOGGER("RoutingTableCalculator");
+INIT_LOGGER(route.RoutingTableCalculator);
void
RoutingTableCalculator::allocateAdjMatrix()
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 81fb9cb..1f88c87 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -32,7 +32,7 @@
namespace nlsr {
-INIT_LOGGER("RoutingTable");
+INIT_LOGGER(route.RoutingTable);
RoutingTable::RoutingTable(ndn::Scheduler& scheduler)
: afterRoutingChange{ndn::make_unique<AfterRoutingChange>()}
diff --git a/src/sequencing-manager.cpp b/src/sequencing-manager.cpp
index cdcbad9..ac2bb54 100644
--- a/src/sequencing-manager.cpp
+++ b/src/sequencing-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -32,7 +32,7 @@
namespace nlsr {
-INIT_LOGGER("SequencingManager");
+INIT_LOGGER(SequencingManager);
void
SequencingManager::writeSeqNoToFile() const
diff --git a/src/tlv/coordinate-lsa.cpp b/src/tlv/coordinate-lsa.cpp
index 02509a0..ab39fe8 100644
--- a/src/tlv/coordinate-lsa.cpp
+++ b/src/tlv/coordinate-lsa.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -21,7 +21,6 @@
#include "coordinate-lsa.hpp"
#include "tlv-nlsr.hpp"
-#include "logger.hpp"
#include <ndn-cxx/util/concepts.hpp>
#include <ndn-cxx/encoding/block-helpers.hpp>
@@ -31,8 +30,6 @@
namespace nlsr {
namespace tlv {
-INIT_LOGGER("CoordinateLsa");
-
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<CoordinateLsa>));
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<CoordinateLsa>));
static_assert(std::is_base_of<ndn::tlv::Error, CoordinateLsa::Error>::value,
diff --git a/src/update/manager-base.cpp b/src/update/manager-base.cpp
index a93aaba..071fc3a 100644
--- a/src/update/manager-base.cpp
+++ b/src/update/manager-base.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -25,7 +25,7 @@
namespace nlsr {
namespace update {
-INIT_LOGGER("UpdatePrefixCommandProcessor");
+INIT_LOGGER(update.PrefixCommandProcessor);
ManagerBase::ManagerBase(ndn::mgmt::Dispatcher& dispatcher,
const std::string& module)
diff --git a/src/update/nfd-rib-command-processor.cpp b/src/update/nfd-rib-command-processor.cpp
index 23a86eb..331a3ca 100644
--- a/src/update/nfd-rib-command-processor.cpp
+++ b/src/update/nfd-rib-command-processor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -20,13 +20,10 @@
**/
#include "nfd-rib-command-processor.hpp"
-#include "logger.hpp"
namespace nlsr {
namespace update {
-INIT_LOGGER("NfdRibProcessor");
-
NfdRibCommandProcessor::NfdRibCommandProcessor(ndn::mgmt::Dispatcher& dispatcher,
NamePrefixList& namePrefixList,
Lsdb& lsdb)
diff --git a/src/update/prefix-update-processor.cpp b/src/update/prefix-update-processor.cpp
index 478380f..26adefd 100644
--- a/src/update/prefix-update-processor.cpp
+++ b/src/update/prefix-update-processor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -29,7 +29,7 @@
namespace nlsr {
namespace update {
-INIT_LOGGER("PrefixUpdateProcessor");
+INIT_LOGGER(update.PrefixUpdateProcessor);
/** \brief an Interest tag to indicate command signer
*/
diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index 896e7b3..dd733fa 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -50,7 +50,6 @@
, lsdb(nlsr.getLsdb())
, rt1(nlsr.getRoutingTable())
{
- INIT_LOGGERS("/tmp/", "TRACE");
nlsr.getConfParameter().setNetwork("/ndn");
nlsr.getConfParameter().setRouterName("/This/Router");
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index 0400b05..2249dab 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -21,7 +21,6 @@
#include "conf-file-processor.hpp"
#include "test-common.hpp"
-#include "logger.hpp"
#include "nlsr.hpp"
#include <fstream>
@@ -45,28 +44,9 @@
" lsa-refresh-time 1800\n"
" lsa-interest-lifetime 3\n"
" router-dead-interval 86400\n"
- " log-level INFO\n"
- " log-dir /tmp\n"
" seq-dir /tmp\n"
"}\n\n";
-const std::string LOG4CXX_PLACEHOLDER = "$LOG4CXX$";
-
-const std::string SECTION_GENERAL_WITH_LOG4CXX =
- "general\n"
- "{\n"
- " network /ndn/\n"
- " site /memphis.edu/\n"
- " router /cs/pollux/\n"
- " lsa-refresh-time 1800\n"
- " lsa-interest-lifetime 3\n"
- " router-dead-interval 86400\n"
- " log-level INFO\n"
- " log-dir /tmp\n"
- " seq-dir /tmp\n"
- " log4cxx-conf " + LOG4CXX_PLACEHOLDER + "\n"
- "}\n\n";
-
const std::string SECTION_NEIGHBORS =
"neighbors\n"
"{\n"
@@ -130,8 +110,6 @@
const std::string CONFIG_LINK_STATE = SECTION_GENERAL + SECTION_NEIGHBORS +
SECTION_HYPERBOLIC_OFF + SECTION_FIB + SECTION_ADVERTISING;
-const std::string CONFIG_LOG4CXX = SECTION_GENERAL_WITH_LOG4CXX;
-
const std::string CONFIG_HYPERBOLIC = SECTION_GENERAL + SECTION_NEIGHBORS +
SECTION_HYPERBOLIC_ON + SECTION_FIB + SECTION_ADVERTISING;
@@ -146,18 +124,12 @@
: face(m_ioService, m_keyChain)
, nlsr(m_ioService, m_scheduler, face, m_keyChain)
, CONFIG_FILE("unit-test-nlsr.conf")
- , m_logConfigFileName(boost::filesystem::unique_path().string())
- , m_logFileName(boost::filesystem::unique_path().string())
{
}
~ConfFileProcessorFixture()
{
remove("unit-test-nlsr.conf");
- remove("/tmp/unit-test-log4cxx.xml");
-
- boost::filesystem::remove(boost::filesystem::path(getLogConfigFileName()));
- boost::filesystem::remove(boost::filesystem::path(getLogFileName()));
}
bool
@@ -173,39 +145,6 @@
}
void
- verifyOutputLog4cxx(const std::string expected[], size_t nExpected)
- {
- std::ifstream is(getLogFileName().c_str());
- std::string buffer((std::istreambuf_iterator<char>(is)),
- (std::istreambuf_iterator<char>()));
-
- std::vector<std::string> components;
- boost::split(components, buffer, boost::is_any_of(" ,\n"));
-
- // expected + number of timestamps (one per log statement) + trailing newline of last statement
- BOOST_REQUIRE_EQUAL(components.size(), nExpected);
-
- for (size_t i = 0; i < nExpected; ++i) {
- if (expected[i] == "")
- continue;
-
- BOOST_CHECK_EQUAL(components[i], expected[i]);
- }
- }
-
- const std::string&
- getLogConfigFileName()
- {
- return m_logConfigFileName;
- }
-
- const std::string&
- getLogFileName()
- {
- return m_logFileName;
- }
-
- void
commentOut(const std::string& key, std::string& config)
{
boost::replace_all(config, key, ";" + key);
@@ -217,8 +156,6 @@
private:
const std::string CONFIG_FILE;
- std::string m_logConfigFileName;
- std::string m_logFileName;
};
BOOST_FIXTURE_TEST_SUITE(TestConfFileProcessor, ConfFileProcessorFixture)
@@ -239,8 +176,6 @@
BOOST_CHECK_EQUAL(conf.getLsaRefreshTime(), 1800);
BOOST_CHECK_EQUAL(conf.getLsaInterestLifetime(), ndn::time::seconds(3));
BOOST_CHECK_EQUAL(conf.getRouterDeadInterval(), 86400);
- BOOST_CHECK_EQUAL(conf.getLogLevel(), "INFO");
- BOOST_CHECK_EQUAL(conf.getLogDir(), "/tmp");
BOOST_CHECK_EQUAL(conf.getSeqFileDir(), "/tmp");
// Neighbors
@@ -274,81 +209,6 @@
BOOST_CHECK_EQUAL(nlsr.getNamePrefixList().size(), 2);
}
-BOOST_AUTO_TEST_CASE(Log4cxxFileExists)
-{
- std::string configPath = boost::filesystem::unique_path().native();
-
- std::ofstream log4cxxConfFile;
- log4cxxConfFile.open(configPath);
- log4cxxConfFile.close();
-
- std::string config = CONFIG_LOG4CXX;
- boost::replace_all(config, LOG4CXX_PLACEHOLDER, configPath);
-
- BOOST_CHECK_EQUAL(processConfigurationString(config), true);
-
- ConfParameter& conf = nlsr.getConfParameter();
- BOOST_CHECK_EQUAL(conf.getLog4CxxConfPath(), configPath);
- BOOST_CHECK_EQUAL(conf.isLog4CxxConfAvailable(), true);
-
- boost::filesystem::remove(boost::filesystem::path(configPath));
-}
-
-BOOST_AUTO_TEST_CASE(Log4cxxFileDoesNotExist)
-{
- std::string configPath = boost::filesystem::unique_path().native();
-
- std::string config = CONFIG_LOG4CXX;
- boost::replace_all(config, LOG4CXX_PLACEHOLDER, configPath);
-
- BOOST_CHECK_EQUAL(processConfigurationString(config), false);
-}
-
-BOOST_AUTO_TEST_CASE(Log4cxxNoValue)
-{
- std::string config = CONFIG_LOG4CXX;
- boost::replace_all(config, LOG4CXX_PLACEHOLDER, "");
-
- BOOST_CHECK_EQUAL(processConfigurationString(config), false);
-}
-
-BOOST_AUTO_TEST_CASE(Log4cxxTestCase)
-{
- {
- std::ofstream of(getLogConfigFileName().c_str());
- of << "log4j.rootLogger=TRACE, FILE\n"
- << "log4j.appender.FILE=org.apache.log4j.FileAppender\n"
- << "log4j.appender.FILE.layout=org.apache.log4j.PatternLayout\n"
- << "log4j.appender.FILE.File=" << getLogFileName() << "\n"
- << "log4j.appender.FILE.ImmediateFlush=true\n"
- << "log4j.appender.FILE.layout.ConversionPattern=%d{HH:mm:ss} %p %c{1} - %m%n\n";
- }
-
- INIT_LOG4CXX(getLogConfigFileName());
-
- INIT_LOGGER("DefaultConfig");
-
- NLSR_LOG_TRACE("trace-message-JHGFDSR^1");
- NLSR_LOG_DEBUG("debug-message-IGg2474fdksd-fo-" << 15 << 16 << 17);
- NLSR_LOG_INFO("info-message-Jjxjshj13");
- NLSR_LOG_WARN("warning-message-XXXhdhd11" << 1 <<"x");
- NLSR_LOG_ERROR("error-message-!#$&^%$#@");
- NLSR_LOG_FATAL("fatal-message-JJSjaamcng");
-
- const std::string EXPECTED[] =
- {
- "", "TRACE", "DefaultConfig", "-", "trace-message-JHGFDSR^1",
- "", "DEBUG", "DefaultConfig", "-", "debug-message-IGg2474fdksd-fo-151617",
- "", "INFO", "DefaultConfig", "-", "info-message-Jjxjshj13",
- "", "WARN", "DefaultConfig", "-", "warning-message-XXXhdhd111x",
- "", "ERROR", "DefaultConfig", "-", "error-message-!#$&^%$#@",
- "", "FATAL", "DefaultConfig", "-", "fatal-message-JJSjaamcng",
- "",
- };
-
- verifyOutputLog4cxx(EXPECTED, sizeof(EXPECTED) / sizeof(std::string));
-}
-
BOOST_AUTO_TEST_CASE(MalformedUri)
{
const std::string MALFORMED_URI =
@@ -402,7 +262,6 @@
commentOut("lsa-refresh-time", config);
commentOut("lsa-interest-lifetime", config);
commentOut("router-dead-interval", config);
- commentOut("log-level", config);
BOOST_CHECK_EQUAL(processConfigurationString(config), true);
@@ -412,7 +271,6 @@
BOOST_CHECK_EQUAL(conf.getLsaInterestLifetime(),
static_cast<ndn::time::seconds>(LSA_INTEREST_LIFETIME_DEFAULT));
BOOST_CHECK_EQUAL(conf.getRouterDeadInterval(), (2*conf.getLsaRefreshTime()));
- BOOST_CHECK_EQUAL(conf.getLogLevel(), "INFO");
}
BOOST_AUTO_TEST_CASE(DefaultValuesNeighbors)
diff --git a/tests/test-fib.cpp b/tests/test-fib.cpp
index 80408eb..d47d3a8 100644
--- a/tests/test-fib.cpp
+++ b/tests/test-fib.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -39,8 +39,6 @@
: face(std::make_shared<ndn::util::DummyClientFace>(m_keyChain))
, interests(face->sentInterests)
{
- INIT_LOGGERS("/tmp", "DEBUG");
-
Adjacent neighbor1(router1Name, ndn::FaceUri(router1FaceUri), 0, Adjacent::STATUS_ACTIVE, 0, router1FaceId);
adjacencies.insert(neighbor1);
diff --git a/tests/test-hyperbolic-calculator.cpp b/tests/test-hyperbolic-calculator.cpp
index dc0cd18..4b8cce7 100644
--- a/tests/test-hyperbolic-calculator.cpp
+++ b/tests/test-hyperbolic-calculator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -57,8 +57,6 @@
void setUpTopology(std::vector<double> anglesA, std::vector<double> anglesB,
std::vector<double> anglesC)
{
- INIT_LOGGERS("/tmp", "TRACE");
-
Adjacent a(ROUTER_A_NAME, ndn::FaceUri(ROUTER_A_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
Adjacent b(ROUTER_B_NAME, ndn::FaceUri(ROUTER_B_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
Adjacent c(ROUTER_C_NAME, ndn::FaceUri(ROUTER_C_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
diff --git a/tests/test-link-state-calculator.cpp b/tests/test-link-state-calculator.cpp
index 31c9abf..c6fafd0 100644
--- a/tests/test-link-state-calculator.cpp
+++ b/tests/test-link-state-calculator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -52,8 +52,6 @@
// Triangle topology with routers A, B, C connected
void setUpTopology()
{
- INIT_LOGGERS("/tmp", "TRACE");
-
ConfParameter& conf = nlsr.getConfParameter();
conf.setNetwork("/ndn");
conf.setSiteName("/router");
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 0142579..197d5cd 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -57,8 +57,6 @@
advanceClocks(ndn::time::milliseconds(1), 10);
face.sentInterests.clear();
-
- INIT_LOGGERS("/tmp", "DEBUG");
}
void
diff --git a/tests/test-name-prefix-table.cpp b/tests/test-name-prefix-table.cpp
index ceeb828..776b447 100644
--- a/tests/test-name-prefix-table.cpp
+++ b/tests/test-name-prefix-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -37,7 +37,6 @@
, lsdb(nlsr.getLsdb())
, npt(nlsr.getNamePrefixTable())
{
- INIT_LOGGERS("/tmp", "DEBUG");
}
public:
diff --git a/tests/test-sync-logic-handler.cpp b/tests/test-sync-logic-handler.cpp
index f696d42..b233b22 100644
--- a/tests/test-sync-logic-handler.cpp
+++ b/tests/test-sync-logic-handler.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2017, The University of Memphis,
+ * Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -24,7 +24,6 @@
#include "common.hpp"
#include "nlsr.hpp"
#include "lsa.hpp"
-#include "logger.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
@@ -59,8 +58,6 @@
conf.buildRouterPrefix();
addIdentity(conf.getRouterPrefix());
-
- INIT_LOGGERS("/tmp", "TRACE");
}
void
diff --git a/wscript b/wscript
index 96f2980..76adf7a 100644
--- a/wscript
+++ b/wscript
@@ -52,16 +52,13 @@
conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
uselib_store='NDN_CXX', mandatory=True)
- conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'],
- uselib_store='LOG4CXX', mandatory=True)
-
- boost_libs = 'system chrono program_options iostreams thread regex filesystem'
+ boost_libs = 'system chrono program_options iostreams thread regex filesystem log log_setup'
if conf.options.with_tests:
conf.env['WITH_TESTS'] = 1
conf.define('WITH_TESTS', 1);
boost_libs += ' unit_test_framework'
- conf.check_boost(lib=boost_libs)
+ conf.check_boost(lib=boost_libs, mt=True)
if conf.env.BOOST_VERSION_NUMBER < 104800:
Logs.error("Minimum required boost version is 1.48.0")
@@ -103,7 +100,7 @@
features='cxx',
source=bld.path.ant_glob(['src/**/*.cpp'],
excl=['src/main.cpp']),
- use='NDN_CXX BOOST LOG4CXX SYNC',
+ use='NDN_CXX BOOST SYNC',
includes='. src',
export_includes='. src')