core: reimplement logging using ndn-cxx's facility
Change-Id: Ifc7c5d70a61ad405dc1f1adfa522a2c0ad1586ab
Refs: #4580
diff --git a/daemon/mgmt/command-authenticator.cpp b/daemon/mgmt/command-authenticator.cpp
index 04f2476..0b6346b 100644
--- a/daemon/mgmt/command-authenticator.cpp
+++ b/daemon/mgmt/command-authenticator.cpp
@@ -41,7 +41,7 @@
namespace nfd {
-NFD_LOG_INIT("CommandAuthenticator");
+NFD_LOG_INIT(CommandAuthenticator);
// INFO: configuration change, etc
// DEBUG: per authentication request result
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index 76fac1c..1d53eab 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -24,6 +24,8 @@
*/
#include "face-manager.hpp"
+
+#include "core/logger.hpp"
#include "face/generic-link-service.hpp"
#include "face/protocol-factory.hpp"
#include "fw/face-table.hpp"
@@ -35,7 +37,7 @@
namespace nfd {
-NFD_LOG_INIT("FaceManager");
+NFD_LOG_INIT(FaceManager);
FaceManager::FaceManager(FaceSystem& faceSystem,
Dispatcher& dispatcher,
diff --git a/daemon/mgmt/fib-manager.cpp b/daemon/mgmt/fib-manager.cpp
index 06e660a..5c04977 100644
--- a/daemon/mgmt/fib-manager.cpp
+++ b/daemon/mgmt/fib-manager.cpp
@@ -24,6 +24,8 @@
*/
#include "fib-manager.hpp"
+
+#include "core/logger.hpp"
#include "fw/face-table.hpp"
#include <ndn-cxx/lp/tags.hpp>
@@ -33,7 +35,7 @@
namespace nfd {
-NFD_LOG_INIT("FibManager");
+NFD_LOG_INIT(FibManager);
FibManager::FibManager(Fib& fib,
const FaceTable& faceTable,
diff --git a/daemon/mgmt/fib-manager.hpp b/daemon/mgmt/fib-manager.hpp
index b5c6984..c5455e9 100644
--- a/daemon/mgmt/fib-manager.hpp
+++ b/daemon/mgmt/fib-manager.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,9 +27,8 @@
#define NFD_DAEMON_MGMT_FIB_MANAGER_HPP
#include "nfd-manager-base.hpp"
-#include "core/logger.hpp"
-#include "table/fib.hpp"
#include "fw/forwarder.hpp"
+#include "table/fib.hpp"
namespace nfd {
@@ -37,7 +36,7 @@
/**
* @brief implement the FIB Management of NFD Management Protocol.
- * @sa http://redmine.named-data.net/projects/nfd/wiki/FibMgmt
+ * @sa https://redmine.named-data.net/projects/nfd/wiki/FibMgmt
*/
class FibManager : public NfdManagerBase
{
diff --git a/daemon/mgmt/general-config-section.cpp b/daemon/mgmt/general-config-section.cpp
index 2b573b3..6ed3af1 100644
--- a/daemon/mgmt/general-config-section.cpp
+++ b/daemon/mgmt/general-config-section.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -24,83 +24,58 @@
*/
#include "general-config-section.hpp"
-
-#include "core/logger.hpp"
#include "core/privilege-helper.hpp"
-#include "core/config-file.hpp"
namespace nfd {
-
namespace general {
-NFD_LOG_INIT("GeneralConfigSection");
-
static void
-onConfig(const ConfigSection& configSection,
- bool isDryRun,
- const std::string& filename)
+onConfig(const ConfigSection& section, bool isDryRun, const std::string&)
{
// general
// {
- // ; user "ndn-user"
- // ; group "ndn-user"
+ // user "ndn-user"
+ // group "ndn-user"
// }
std::string user;
std::string group;
- for (ConfigSection::const_iterator i = configSection.begin();
- i != configSection.end();
- ++i)
- {
- if (i->first == "user")
- {
- try
- {
- user = i->second.get_value<std::string>("user");
+ for (const auto& i : section) {
+ if (i.first == "user") {
+ try {
+ user = i.second.get_value<std::string>("user");
- if (user.empty())
- {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"user\""
- " in \"general\" section"));
- }
- }
- catch (const boost::property_tree::ptree_error& error)
- {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"user\""
- " in \"general\" section"));
- }
+ if (user.empty()) {
+ BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"user\" in \"general\" section"));
}
- else if (i->first == "group")
- {
- try
- {
- group = i->second.get_value<std::string>("group");
-
- if (group.empty())
- {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"group\""
- " in \"general\" section"));
- }
- }
- catch (const boost::property_tree::ptree_error& error)
- {
- BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"group\""
- " in \"general\" section"));
- }
- }
+ }
+ catch (const boost::property_tree::ptree_error&) {
+ BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"user\" in \"general\" section"));
+ }
}
- NFD_LOG_TRACE("using user \"" << user << "\" group \"" << group << "\"");
+ else if (i.first == "group") {
+ try {
+ group = i.second.get_value<std::string>("group");
+
+ if (group.empty()) {
+ BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"group\" in \"general\" section"));
+ }
+ }
+ catch (const boost::property_tree::ptree_error&) {
+ BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"group\" in \"general\" section"));
+ }
+ }
+ }
PrivilegeHelper::initialize(user, group);
}
void
-setConfigFile(ConfigFile& configFile)
+setConfigFile(ConfigFile& config)
{
- configFile.addSectionHandler("general", &onConfig);
+ config.addSectionHandler("general", &onConfig);
}
} // namespace general
-
} // namespace nfd
diff --git a/daemon/mgmt/general-config-section.hpp b/daemon/mgmt/general-config-section.hpp
index 6ce5473..a70bc48 100644
--- a/daemon/mgmt/general-config-section.hpp
+++ b/daemon/mgmt/general-config-section.hpp
@@ -1,11 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014 Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology,
+ * The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -20,22 +21,20 @@
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
#ifndef NFD_MGMT_GENERAL_CONFIG_SECTION_HPP
#define NFD_MGMT_GENERAL_CONFIG_SECTION_HPP
+#include "core/config-file.hpp"
+
namespace nfd {
-
-class ConfigFile;
-
namespace general {
void
-setConfigFile(ConfigFile& configFile);
+setConfigFile(ConfigFile& config);
} // namespace general
-
} // namespace nfd
#endif // NFD_MGMT_GENERAL_CONFIG_SECTION_HPP
diff --git a/daemon/mgmt/strategy-choice-manager.cpp b/daemon/mgmt/strategy-choice-manager.cpp
index 6cb5d57..8f7cef0 100644
--- a/daemon/mgmt/strategy-choice-manager.cpp
+++ b/daemon/mgmt/strategy-choice-manager.cpp
@@ -24,13 +24,15 @@
*/
#include "strategy-choice-manager.hpp"
+
+#include "core/logger.hpp"
#include "table/strategy-choice.hpp"
+
#include <ndn-cxx/mgmt/nfd/strategy-choice.hpp>
-#include <boost/lexical_cast.hpp>
namespace nfd {
-NFD_LOG_INIT("StrategyChoiceManager");
+NFD_LOG_INIT(StrategyChoiceManager);
StrategyChoiceManager::StrategyChoiceManager(StrategyChoice& strategyChoice,
Dispatcher& dispatcher,