[bugfix][T108] [task-view-1792] Solve LOG usage eror problem
Only Configure: No
Affected branch: GSW_V1453
Affected module: log
Self-test: yes
Doc Update: no
Change-Id: I805cc346965cb707e4d96050f53799ccfcc0ac28
diff --git a/mbtk/libgsw_lib/gsw_log_interface.h b/mbtk/libgsw_lib/gsw_log_interface.h
index 98dc7b6..cc59c0f 100755
--- a/mbtk/libgsw_lib/gsw_log_interface.h
+++ b/mbtk/libgsw_lib/gsw_log_interface.h
@@ -32,40 +32,30 @@
int init_log_func(void);
+
#define LOG(level, tag, fmt, args...) \
- do { \
- char *file_ptr_1001 = __FILE__; \
- char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
- char line_1001[10] = {0}; \
- sprintf(line_1001, "%d", __LINE__); \
- while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
- if(*ptr_1001 == '/') \
- break; \
- ptr_1001--; \
- } \
- if(0 == init_log_func()) {\
- gsw_fun_ptr_log(level, "%s#%s: [%s] " fmt, ptr_1001 + 1, line_1001, tag, ##args); \
- } else { \
- printf("%s#%s: [LOG_INIT_ERROR] [%s] " fmt, ptr_1001 + 1, line_1001, tag, ##args); \
- }\
- } while(0)
+ do { \
+ char *file_ptr_1001 = __FILE__; \
+ char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1; \
+ char line_1001[10] = {0}; \
+ sprintf(line_1001, "%d", __LINE__); \
+ while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \
+ if(*ptr_1001 == '/') \
+ break; \
+ ptr_1001--; \
+ } \
+ if(0 == init_log_func()) {\
+ gsw_fun_ptr_log(level, "%s#%s: %s " fmt, ptr_1001 + 1, line_1001, tag, ##args); \
+ } else { \
+ printf("%s#%s: [%s] %s " fmt "\n", ptr_1001 + 1, line_1001, #level, tag, ##args); \
+ } \
+ } while(0)
-#define _GET_MACRO(_1, _2, _3, NAME, ...) NAME
-#define LOGV(...) _GET_MACRO(__VA_ARGS__, LOGV_2, LOGV_1)(__VA_ARGS__)
-#define LOGV_1(fmt, args...) LOG(LOG_VERBOSE_LEVEL, "DEFAULT", fmt, ##args)
-#define LOGV_2(tag, fmt, args...) LOG(LOG_VERBOSE_LEVEL, tag, fmt, ##args)
-
-#define LOGI(...) _GET_MACRO(__VA_ARGS__, LOGI_2, LOGI_1)(__VA_ARGS__)
-#define LOGI_1(fmt, args...) LOG(LOG_INFO_LEVEL, "DEFAULT", fmt, ##args)
-#define LOGI_2(tag, fmt, args...) LOG(LOG_INFO_LEVEL, tag, fmt, ##args)
-
-#define LOGW(...) _GET_MACRO(__VA_ARGS__, LOGW_2, LOGW_1)(__VA_ARGS__)
-#define LOGW_1(fmt, args...) LOG(LOG_WARN_LEVEL, "DEFAULT", fmt, ##args)
-#define LOGW_2(tag, fmt, args...) LOG(LOG_WARN_LEVEL, tag, fmt, ##args)
-
-#define LOGE(...) _GET_MACRO(__VA_ARGS__, LOGE_2, LOGE_1)(__VA_ARGS__)
-#define LOGE_1(fmt, args...) LOG(LOG_ERR_LEVEL, "DEFAULT", fmt, ##args)
-#define LOGE_2(tag, fmt, args...) LOG(LOG_ERR_LEVEL, tag, fmt, ##args)
+#define LOGV(tag, fmt, args...) LOG(LOG_VERBOSE_LEVEL, tag, fmt, ##args)
+#define LOGD(tag, fmt, args...) LOG(LOG_DEBUG_LEVEL, tag, fmt, ##args)
+#define LOGI(tag, fmt, args...) LOG(LOG_INFO_LEVEL, tag, fmt, ##args)
+#define LOGW(tag, fmt, args...) LOG(LOG_WARN_LEVEL, tag, fmt, ##args)
+#define LOGE(tag, fmt, args...) LOG(LOG_ERR_LEVEL, tag, fmt, ##args)
#endif