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__); } \
#define LOGGERIMPL_H_
#include <string>
-#include <tuple>
#include <sstream>
#include <dlog.h>
MAX = DLOG_PRIO_MAX/**< Keep this always at the end. */
};
-template <size_t N>
-struct SizeT
-{
-};
-
-template < typename TupleType>
-void iterateTuple(std::stringstream & stream, TupleType & tuple)
-{
- iterateTuple(stream, tuple, SizeT<std::tuple_size<TupleType>::value>());
-}
-
-template <typename TupleType>
-void iterateTuple(std::stringstream & stream, TupleType& tuple, SizeT<0> )
-{
-}
-
-template <typename TupleType, size_t N >
-void iterateTuple(std::stringstream & stream, TupleType& tuple, SizeT<N>)
-{
- iterateTuple(stream, tuple, SizeT<N-1>());
- stream<<std::get<N-1>(tuple);
-}
-
template<typename... Tail>
-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<Tail...> tuple = std::make_tuple(msg...);
- iterateTuple(messageStr, tuple);
+ std::ostringstream messageStr;
+ std::initializer_list<bool> { (messageStr << msg, true)... };
dlog_print( static_cast<log_priority>(prior)
, tag, "%s: %s(%d) -> %s", file, function, line
, messageStr.str().c_str());
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_ */
{
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<log_priority>(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<log_priority>(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());
}