From: Denis Dolzhenko Date: Thu, 10 Nov 2016 13:54:27 +0000 (+0200) Subject: Update logger. X-Git-Tag: submit/tizen_3.0/20161111.100808^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=144b8d304e5c6959f9ac81dea1c861bcbf8b4e3c;p=profile%2Fmobile%2Fapps%2Fnative%2Fmessage.git Update logger. Change-Id: I7f24f9af8e1e5338de9a7ac511d0f346e730bdd6 Signed-off-by: Denis Dolzhenko --- diff --git a/src/Common/Utils/inc/Logger.h b/src/Common/Utils/inc/Logger.h index cca9c999..6413d1a5 100644 --- a/src/Common/Utils/inc/Logger.h +++ b/src/Common/Utils/inc/Logger.h @@ -29,16 +29,16 @@ LoggerImpl __tmp_logger_unique(LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__);\ #define MSG_LOG(...)\ - logTuple(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_LOG_INFO(...)\ - logTuple(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_LOG_ERROR(...)\ - logTuple(LogPriority::ERROR, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::ERROR, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_LOG_WARN(...)\ - logTuple(LogPriority::WARN, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::WARN, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_ASSERT(expr, ...)\ if(!(expr)) { MSG_LOG_ERROR(__VA_ARGS__); } \ diff --git a/src/Common/Utils/inc/LoggerImpl.h b/src/Common/Utils/inc/LoggerImpl.h index 6c2d7bad..516d6c08 100644 --- a/src/Common/Utils/inc/LoggerImpl.h +++ b/src/Common/Utils/inc/LoggerImpl.h @@ -18,7 +18,6 @@ #define LOGGERIMPL_H_ #include -#include #include #include @@ -35,38 +34,14 @@ enum class LogPriority MAX = DLOG_PRIO_MAX/**< Keep this always at the end. */ }; -template -struct SizeT -{ -}; - -template < typename TupleType> -void iterateTuple(std::stringstream & stream, TupleType & tuple) -{ - iterateTuple(stream, tuple, SizeT::value>()); -} - -template -void iterateTuple(std::stringstream & stream, TupleType& tuple, SizeT<0> ) -{ -} - -template -void iterateTuple(std::stringstream & stream, TupleType& tuple, SizeT) -{ - iterateTuple(stream, tuple, SizeT()); - stream<(tuple); -} - template -void logTuple( LogPriority prior +void loggerImpl(LogPriority prior , const char *tag - , const char * file, const char * function, int line + , const char *file, const char *function, int line , Tail... msg) { - std::stringstream messageStr; - std::tuple tuple = std::make_tuple(msg...); - iterateTuple(messageStr, tuple); + std::ostringstream messageStr; + std::initializer_list { (messageStr << msg, true)... }; dlog_print( static_cast(prior) , tag, "%s: %s(%d) -> %s", file, function, line , messageStr.str().c_str()); @@ -75,12 +50,13 @@ void logTuple( LogPriority prior class LoggerImpl { public: - LoggerImpl(const char *tag, const char * file, const char * function, int line); + LoggerImpl(const char *tag, const char *file, const char *function, int line); ~LoggerImpl(); + private: - const std::string mtag; - const std::string mfile; - const std::string mfunction; + const std::string m_Tag; + const std::string m_File; + const std::string m_Function; }; #endif /* LOGGERIMPL_H_ */ diff --git a/src/Common/Utils/src/LoggerImpl.cpp b/src/Common/Utils/src/LoggerImpl.cpp index f693c546..c7792427 100644 --- a/src/Common/Utils/src/LoggerImpl.cpp +++ b/src/Common/Utils/src/LoggerImpl.cpp @@ -20,27 +20,27 @@ namespace { const std::string enterFraseFormat = "%s: %s(%d) -> [ENTER]"; const std::string leaveFraseFormat = "%s: %s -> [LEAVE]"; - LogPriority defaultPriority = LogPriority::DEBUG; + const log_priority defaultPriority = DLOG_DEBUG; } -LoggerImpl::LoggerImpl(const char *tag, const char * file, const char * function, int line) - : mtag(tag) - , mfile(file) - , mfunction(function) +LoggerImpl::LoggerImpl(const char *tag, const char *file, const char *function, int line) + : m_Tag(tag) + , m_File(file) + , m_Function(function) { - dlog_print( static_cast(defaultPriority) - , mtag.c_str() + dlog_print( defaultPriority + , m_Tag.c_str() , enterFraseFormat.c_str() - , mfile.c_str() - , mfunction.c_str() + , m_File.c_str() + , m_Function.c_str() , line); } LoggerImpl::~LoggerImpl() { - dlog_print( static_cast(defaultPriority) - , mtag.c_str() + dlog_print( defaultPriority + , m_Tag.c_str() , leaveFraseFormat.c_str() - , mfile.c_str() - , mfunction.c_str()); + , m_File.c_str() + , m_Function.c_str()); }