core: Logger extension to allow in-class-defined logger
Change-Id: Ifa31fb65eda772df47a81ad5db1c501eaa5f8ca1
diff --git a/daemon/core/logger.hpp b/daemon/core/logger.hpp
index e483ac9..6732384 100644
--- a/daemon/core/logger.hpp
+++ b/daemon/core/logger.hpp
@@ -50,10 +50,24 @@
std::ostream&
operator<<(std::ostream& output, const Logger& obj);
-#define NFD_LOG_INIT(name) \
+#define NFD_LOG_INIT(name) \
static nfd::Logger \
g_logger = nfd::Logger(name);
+#define NFD_LOG_INCLASS_DECLARE() \
+ static nfd::Logger g_logger;
+
+#define NFD_LOG_INCLASS_DEFINE(cls, name) \
+ nfd::Logger cls::g_logger = nfd::Logger(name);
+
+#define NFD_LOG_INCLASS_TEMPLATE_DEFINE(cls, name) \
+ template<class T> \
+ nfd::Logger cls<T>::g_logger = nfd::Logger(name);
+
+#define NFD_LOG_INCLASS_TEMPLATE_SPECIALIZATION_DEFINE(cls, specialization, name) \
+ template<> \
+ nfd::Logger cls<specialization>::g_logger = nfd::Logger(name);
+
#define NFD_LOG_TRACE(expression) \
if(g_logger.isEnabled(nfd::LOG_TRACE)) \
std::cerr<<"TRACE: "<<"["<<g_logger<<"] " << expression << "\n"