DSDebug: fix to print 'domain' before the funtion name 64/241864/1
authorSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 05:58:40 +0000 (14:58 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:12:22 +0000 (19:12 +0900)
Change-Id: I1fcfdad9d29980c7017e02bd067dba32cd7b9fbe
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/DSDebug/DSDebugLog.cpp
src/DSDebug/DSDebugLog.h
tests/DSDebugLog-test.cpp

index fd15355..2900668 100644 (file)
@@ -53,7 +53,7 @@ DSDebugLog *DSDebugLog::GetInstance()
        return mInstance;
 }
 
-void DSDebugLog::printLog(int logLevel, const char *funcName, int line, const char *fmt, ...)
+void DSDebugLog::printLog(int logLevel, const char *domain, const char *funcName, int line, const char *fmt, ...)
 {
        //TODO: apply logLevel
        //TODO: use dlog or stdout
@@ -65,7 +65,8 @@ void DSDebugLog::printLog(int logLevel, const char *funcName, int line, const ch
        va_start(arg, fmt);
        printf("%s", color[logLevel]);
        printf("[%s]", lvl_str[logLevel]);
-       printf(":[%s(%d)]", funcName, line);
+       printf("[%s]", domain);
+       printf(":[%s(%d)]:", funcName, line);
        vprintf(fmt, arg);
        printf("\n");
        va_end(arg);
index d9a3dad..12be42e 100644 (file)
@@ -45,7 +45,7 @@ public:
        void operator=(const DSDebugLog &) = delete; // should not be assignable
 
        static DSDebugLog *GetInstance();
-       void printLog(int logLevel, const char *funcName, int line, const char *fmt, ...);
+       void printLog(int logLevel, const char *domain, const char *funcName, int line, const char *fmt, ...);
        int getLogLevel();
 
 private:
@@ -60,28 +60,28 @@ private:
 #define DSLOG_DBG(domain, fmt, args...)                                  \
        do {                                                                 \
                DSDebugLog *log = DSDebugLog::GetInstance();                     \
-               log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, __func__, __LINE__, "[" domain "]: " fmt, \
+               log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, domain, __func__, __LINE__, fmt, \
                                          ##args);                                           \
        } while (0)
 
 #define DSLOG_INF(domain, fmt, args...)                                 \
        do {                                                                \
                DSDebugLog *log = DSDebugLog::GetInstance();                    \
-               log->printLog(DSDebugLog::LOG_LEVEL_INFO, __func__, __LINE__, "[" domain "]: " fmt, \
+               log->printLog(DSDebugLog::LOG_LEVEL_INFO, domain, __func__, __LINE__, fmt, \
                                          ##args);                                          \
        } while (0)
 
 #define DSLOG_WRN(domain, fmt, args...)                                 \
        do {                                                                \
                DSDebugLog *log = DSDebugLog::GetInstance();                    \
-               log->printLog(DSDebugLog::LOG_LEVEL_WARN, __func__, __LINE__, "[" domain "]: " fmt, \
+               log->printLog(DSDebugLog::LOG_LEVEL_WARN, domain, __func__, __LINE__, fmt, \
                                          ##args);                                          \
        } while (0)
 
 #define DSLOG_ERR(domain, fmt, args...)                                \
        do {                                                               \
                DSDebugLog *log = DSDebugLog::GetInstance();                   \
-               log->printLog(DSDebugLog::LOG_LEVEL_ERR, __func__, __LINE__, "[" domain "]: " fmt, \
+               log->printLog(DSDebugLog::LOG_LEVEL_ERR, domain, __func__, __LINE__, fmt, \
                                          ##args);                                         \
        } while (0)
 }
index 71265ed..78322b4 100644 (file)
@@ -46,10 +46,10 @@ TEST_F(DSDebugLogTest, PrintLog)
        const char *str = "Hi world";
        DSDebugLog *log = DSDebugLog::GetInstance();
 
-       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");
+       log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, "DSDebugLogTest", __func__, __LINE__, "Hello world");
+       log->printLog(DSDebugLog::LOG_LEVEL_INFO, "DSDebugLogTest", __func__, __LINE__, "%s", str);
+       log->printLog(DSDebugLog::LOG_LEVEL_WARN, "DSDebugLogTest", __func__, __LINE__, "Greeting world");
+       log->printLog(DSDebugLog::LOG_LEVEL_ERR, "DSDebugLogTest", __func__, __LINE__, "Hey world");
 
        EXPECT_TRUE(true);
 }