diff options
Diffstat (limited to 'include/hmi-debug.h')
-rw-r--r-- | include/hmi-debug.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/hmi-debug.h b/include/hmi-debug.h index 2bd3478..282386c 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, ...) @@ -95,4 +97,21 @@ static void _HMI_SEQ_LOG(enum LOG_LEVEL level, const char* file, const char* fun 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 |