X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=include%2Fhmi-debug.h;h=a70b49b85a39e517be17521ce7e8de47843bad80;hb=0af492685eb4a180ec3cef86338eb5dd3d8c3383;hp=2bd3478f3dbea7afeb774f8b3f3f952f4ac73312;hpb=807c2bc45bf19059021eb3d94e2c1693a9c940b6;p=apps%2Fagl-service-windowmanager.git diff --git a/include/hmi-debug.h b/include/hmi-debug.h index 2bd3478..a70b49b 100644 --- a/include/hmi-debug.h +++ b/include/hmi-debug.h @@ -47,6 +47,8 @@ enum LOG_LEVEL{ #define HMI_SEQ_INFO(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) #define HMI_SEQ_DEBUG(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) +#define DUMP(args, ...) _DUMP(LOG_LEVEL_DEBUG, args, ##__VA_ARGS__) + static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"}; static void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...) @@ -91,8 +93,25 @@ static void _HMI_SEQ_LOG(enum LOG_LEVEL level, const char* file, const char* fun va_start(args, log); if (log == NULL || vasprintf(&message, log, args) < 0) message = NULL; - fprintf(stderr, "[%10.3f] [wm %s] [%s, %s(), Line:%d] >>> seq %d: %s \n", time / 1000.0, ERROR_FLAG[level], file, func, line, seq_num, message); + fprintf(stderr, "[%10.3f] [wm %s] [%s, %s(), Line:%d] >>> req %d: %s \n", time / 1000.0, ERROR_FLAG[level], file, func, line, seq_num, message); va_end(args); free(message); } + +static void _DUMP(enum LOG_LEVEL level, const char *log, ...) +{ + const int log_level = (getenv("USE_HMI_DEBUG") == NULL) ? LOG_LEVEL_ERROR : atoi(getenv("USE_HMI_DEBUG")); + if (log_level < level) + { + return; + } + char *message; + va_list args; + va_start(args, log); + if (log == NULL || vasprintf(&message, log, args) < 0) + message = NULL; + fprintf(stderr, "%s \n", message); + va_end(args); + free(message); +} #endif //__HMI_DEBUG_H__ \ No newline at end of file