util: rename NDN_CXX_LOG_* macros to NDN_LOG_*
refs #3562
Change-Id: I7366d20e064d483a852c39def523644950d2f2e3
diff --git a/src/util/logger.hpp b/src/util/logger.hpp
index 58e7b2a..4f0c35b 100644
--- a/src/util/logger.hpp
+++ b/src/util/logger.hpp
@@ -57,7 +57,7 @@
parseLogLevel(const std::string& s);
/** \brief represents a logger in logging facility
- * \note User should declare a new logger with \p NDN_CXX_LOG_INIT macro.
+ * \note User should declare a new logger with \p NDN_LOG_INIT macro.
*/
class Logger : public boost::log::sources::logger_mt
{
@@ -90,7 +90,7 @@
/** \brief declare a log module
*/
-#define NDN_CXX_LOG_INIT(name) \
+#define NDN_LOG_INIT(name) \
namespace { \
inline ::ndn::util::Logger& getNdnCxxLogger() \
{ \
@@ -117,15 +117,15 @@
#if (BOOST_VERSION >= 105900) && (BOOST_VERSION < 106000)
// workaround Boost bug 11549
-#define NDN_CXX_BOOST_LOG(x) BOOST_LOG(x) << ""
+#define NDN_BOOST_LOG(x) BOOST_LOG(x) << ""
#else
-#define NDN_CXX_BOOST_LOG(x) BOOST_LOG(x)
+#define NDN_BOOST_LOG(x) BOOST_LOG(x)
#endif
-#define NDN_CXX_LOG(lvl, lvlstr, expression) \
+#define NDN_LOG(lvl, lvlstr, expression) \
do { \
if (getNdnCxxLogger().isLevelEnabled(::ndn::util::LogLevel::lvl)) { \
- NDN_CXX_BOOST_LOG(getNdnCxxLogger()) << ::ndn::util::LoggerTimestamp{} \
+ NDN_BOOST_LOG(getNdnCxxLogger()) << ::ndn::util::LoggerTimestamp{} \
<< " " BOOST_STRINGIZE(lvlstr) ": [" << getNdnCxxLogger().getModuleName() << "] " \
<< expression; \
} \
@@ -134,32 +134,32 @@
/** \brief log at TRACE level
* \pre A log module must be declared in the same translation unit.
*/
-#define NDN_CXX_LOG_TRACE(expression) NDN_CXX_LOG(TRACE, TRACE, expression)
+#define NDN_LOG_TRACE(expression) NDN_LOG(TRACE, TRACE, expression)
/** \brief log at DEBUG level
* \pre A log module must be declared in the same translation unit.
*/
-#define NDN_CXX_LOG_DEBUG(expression) NDN_CXX_LOG(DEBUG, DEBUG, expression)
+#define NDN_LOG_DEBUG(expression) NDN_LOG(DEBUG, DEBUG, expression)
/** \brief log at INFO level
* \pre A log module must be declared in the same translation unit.
*/
-#define NDN_CXX_LOG_INFO(expression) NDN_CXX_LOG(INFO, INFO, expression)
+#define NDN_LOG_INFO(expression) NDN_LOG(INFO, INFO, expression)
/** \brief log at WARN level
* \pre A log module must be declared in the same translation unit.
*/
-#define NDN_CXX_LOG_WARN(expression) NDN_CXX_LOG(WARN, WARNING, expression)
+#define NDN_LOG_WARN(expression) NDN_LOG(WARN, WARNING, expression)
/** \brief log at ERROR level
* \pre A log module must be declared in the same translation unit.
*/
-#define NDN_CXX_LOG_ERROR(expression) NDN_CXX_LOG(ERROR, ERROR, expression)
+#define NDN_LOG_ERROR(expression) NDN_LOG(ERROR, ERROR, expression)
/** \brief log at FATAL level
* \pre A log module must be declared in the same translation unit.
*/
-#define NDN_CXX_LOG_FATAL(expression) NDN_CXX_LOG(FATAL, FATAL, expression)
+#define NDN_LOG_FATAL(expression) NDN_LOG(FATAL, FATAL, expression)
} // namespace util
} // namespace ndn
diff --git a/src/util/logging.cpp b/src/util/logging.cpp
index dd10c4d..89d0fd7 100644
--- a/src/util/logging.cpp
+++ b/src/util/logging.cpp
@@ -44,7 +44,7 @@
{
this->setDestinationImpl(shared_ptr<std::ostream>(&std::clog, bind([]{})));
- const char* environ = std::getenv("NDN_CXX_LOG");
+ const char* environ = std::getenv("NDN_LOG");
if (environ != nullptr) {
this->setLevelImpl(environ);
}
diff --git a/src/util/logging.hpp b/src/util/logging.hpp
index af000c4..96e1bcb 100644
--- a/src/util/logging.hpp
+++ b/src/util/logging.hpp
@@ -43,7 +43,7 @@
{
public:
/** \brief register a new logger
- * \note App should declare a new logger with \p NDN_CXX_LOG_INIT macro.
+ * \note App should declare a new logger with \p NDN_LOG_INIT macro.
*/
static void
addLogger(Logger& logger);
diff --git a/tests/unit-tests/util/log-module1.cpp b/tests/unit-tests/util/log-module1.cpp
index dab7577..9641ef2 100644
--- a/tests/unit-tests/util/log-module1.cpp
+++ b/tests/unit-tests/util/log-module1.cpp
@@ -18,9 +18,10 @@
*
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
+
#include "util/logger.hpp"
-NDN_CXX_LOG_INIT(Module1);
+NDN_LOG_INIT(Module1);
namespace ndn {
namespace util {
@@ -29,12 +30,12 @@
void
logFromModule1()
{
- NDN_CXX_LOG_TRACE("trace" << 1);
- NDN_CXX_LOG_DEBUG("debug" << 1);
- NDN_CXX_LOG_INFO("info" << 1);
- NDN_CXX_LOG_WARN("warn" << 1);
- NDN_CXX_LOG_ERROR("error" << 1);
- NDN_CXX_LOG_FATAL("fatal" << 1);
+ NDN_LOG_TRACE("trace" << 1);
+ NDN_LOG_DEBUG("debug" << 1);
+ NDN_LOG_INFO("info" << 1);
+ NDN_LOG_WARN("warn" << 1);
+ NDN_LOG_ERROR("error" << 1);
+ NDN_LOG_FATAL("fatal" << 1);
}
} // namespace tests
diff --git a/tests/unit-tests/util/log-module2.cpp b/tests/unit-tests/util/log-module2.cpp
index 550aa53..37e86d0 100644
--- a/tests/unit-tests/util/log-module2.cpp
+++ b/tests/unit-tests/util/log-module2.cpp
@@ -18,9 +18,10 @@
*
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
+
#include "util/logger.hpp"
-NDN_CXX_LOG_INIT(Module2);
+NDN_LOG_INIT(Module2);
namespace ndn {
namespace util {
@@ -29,12 +30,12 @@
void
logFromModule2()
{
- NDN_CXX_LOG_TRACE("trace" << 2);
- NDN_CXX_LOG_DEBUG("debug" << 2);
- NDN_CXX_LOG_INFO("info" << 2);
- NDN_CXX_LOG_WARN("warn" << 2);
- NDN_CXX_LOG_ERROR("error" << 2);
- NDN_CXX_LOG_FATAL("fatal" << 2);
+ NDN_LOG_TRACE("trace" << 2);
+ NDN_LOG_DEBUG("debug" << 2);
+ NDN_LOG_INFO("info" << 2);
+ NDN_LOG_WARN("warn" << 2);
+ NDN_LOG_ERROR("error" << 2);
+ NDN_LOG_FATAL("fatal" << 2);
}
} // namespace tests
diff --git a/tests/unit-tests/util/logging.t.cpp b/tests/unit-tests/util/logging.t.cpp
index da60ce1..f47b5a9 100644
--- a/tests/unit-tests/util/logging.t.cpp
+++ b/tests/unit-tests/util/logging.t.cpp
@@ -18,6 +18,7 @@
*
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
+
#include "util/logging.hpp"
#include "util/logger.hpp"
@@ -46,12 +47,12 @@
Logger& logger = *loggerPtr;
auto getNdnCxxLogger = [&logger] () -> Logger& { return logger; };
- NDN_CXX_LOG_TRACE("trace" << moduleName);
- NDN_CXX_LOG_DEBUG("debug" << moduleName);
- NDN_CXX_LOG_INFO("info" << moduleName);
- NDN_CXX_LOG_WARN("warn" << moduleName);
- NDN_CXX_LOG_ERROR("error" << moduleName);
- NDN_CXX_LOG_FATAL("fatal" << moduleName);
+ NDN_LOG_TRACE("trace" << moduleName);
+ NDN_LOG_DEBUG("debug" << moduleName);
+ NDN_LOG_INFO("info" << moduleName);
+ NDN_LOG_WARN("warn" << moduleName);
+ NDN_LOG_ERROR("error" << moduleName);
+ NDN_LOG_FATAL("fatal" << moduleName);
BOOST_CHECK(Logging::get().removeLogger(logger));
}