From 10d5116851d51facbae446ad00b7de535c3b58ef Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 25 Mar 2015 21:14:12 +0100 Subject: [PATCH] [DEV] update Log interafce --- etk/debug.h | 12 ++---------- etk/log.h | 11 +++++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/etk/debug.h b/etk/debug.h index ec3e2bb..91df8c8 100644 --- a/etk/debug.h +++ b/etk/debug.h @@ -16,16 +16,8 @@ namespace etk { int32_t getLogId(); }; -// TODO : Review this problem of multiple intanciation of "std::stringbuf sb" -#define ETK_BASE(info,data) \ - do { \ - if (info <= etk::log::getLevel(etk::getLogId())) { \ - std::stringbuf sb; \ - std::ostream tmpStream(&sb); \ - tmpStream << data; \ - etk::log::logStream(etk::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \ - } \ - } while(0) + +#define ETK_BASE(info,data) TK_LOG_BASE(etk::getLogId(),info,data) #define TK_CRITICAL(data) ETK_BASE(1, data) #define TK_ERROR(data) ETK_BASE(2, data) diff --git a/etk/log.h b/etk/log.h index 54c304e..90c2d99 100644 --- a/etk/log.h +++ b/etk/log.h @@ -132,4 +132,15 @@ namespace etk { #endif #define __class__ (NULL) +// generic define for all logs:: +#define TK_LOG_BASE(logId,info,data) \ + do { \ + if (info <= etk::log::getLevel(logId)) { \ + std::stringbuf sb; \ + std::ostream tmpStream(&sb); \ + tmpStream << data; \ + etk::log::logStream(logId, info, __LINE__, __class__, __func__, tmpStream); \ + } \ + } while(0) + #endif