return mInstance;
}
-void DSDebugLog::printLog(int logLevel, const char *funcName, const char *fmt, ...)
+void DSDebugLog::printLog(int logLevel, const char *funcName, int line, const char *fmt, ...)
{
//TODO: apply logLevel
//TODO: use dlog or stdout
va_start(arg, fmt);
printf("%s", color[logLevel]);
printf("[%s]", lvl_str[logLevel]);
- printf(":[%s]", funcName);
+ printf(":[%s(%d)]", funcName, line);
vprintf(fmt, arg);
printf("\n");
va_end(arg);
void operator=(const DSDebugLog &) = delete; // should not be assignable
static DSDebugLog *GetInstance();
- void printLog(int logLevel, const char *funcName, const char *fmt, ...);
+ void printLog(int logLevel, const char *funcName, int line, const char *fmt, ...);
int getLogLevel();
private:
#define DSLOG_DBG(domain, fmt, args...) \
do { \
DSDebugLog *log = DSDebugLog::GetInstance(); \
- log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, __func__, "[" domain "]: " fmt, \
+ log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, __func__, __LINE__, "[" domain "]: " fmt, \
##args); \
} while (0)
#define DSLOG_INF(domain, fmt, args...) \
do { \
DSDebugLog *log = DSDebugLog::GetInstance(); \
- log->printLog(DSDebugLog::LOG_LEVEL_INFO, __func__, "[" domain "]: " fmt, \
+ log->printLog(DSDebugLog::LOG_LEVEL_INFO, __func__, __LINE__, "[" domain "]: " fmt, \
##args); \
} while (0)
#define DSLOG_WRN(domain, fmt, args...) \
do { \
DSDebugLog *log = DSDebugLog::GetInstance(); \
- log->printLog(DSDebugLog::LOG_LEVEL_WARN, __func__, "[" domain "]: " fmt, \
+ log->printLog(DSDebugLog::LOG_LEVEL_WARN, __func__, __LINE__, "[" domain "]: " fmt, \
##args); \
} while (0)
#define DSLOG_ERR(domain, fmt, args...) \
do { \
DSDebugLog *log = DSDebugLog::GetInstance(); \
- log->printLog(DSDebugLog::LOG_LEVEL_ERR, __func__, "[" domain "]: " fmt, \
+ log->printLog(DSDebugLog::LOG_LEVEL_ERR, __func__, __LINE__, "[" domain "]: " fmt, \
##args); \
} while (0)
}
const char *str = "Hi world";
DSDebugLog *log = DSDebugLog::GetInstance();
- log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, __func__, "Hello world");
- log->printLog(DSDebugLog::LOG_LEVEL_INFO, __func__, "%s", str);
- log->printLog(DSDebugLog::LOG_LEVEL_WARN, __func__, "Greeting world");
- log->printLog(DSDebugLog::LOG_LEVEL_ERR, __func__, "Hey world");
+ log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, __func__, __LINE__, "Hello world");
+ log->printLog(DSDebugLog::LOG_LEVEL_INFO, __func__, __LINE__, "%s", str);
+ log->printLog(DSDebugLog::LOG_LEVEL_WARN, __func__, __LINE__, "Greeting world");
+ log->printLog(DSDebugLog::LOG_LEVEL_ERR, __func__, __LINE__, "Hey world");
EXPECT_TRUE(true);
}