17 #ifndef __HMI_DEBUG_H__ 18 #define __HMI_DEBUG_H__ 36 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) 38 #define HMI_ERROR(prefix, args,...) _HMI_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, prefix, args, ##__VA_ARGS__) 39 #define HMI_WARNING(prefix, args,...) _HMI_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) 40 #define HMI_NOTICE(prefix, args,...) _HMI_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) 41 #define HMI_INFO(prefix, args,...) _HMI_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) 42 #define HMI_DEBUG(prefix, args,...) _HMI_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) 44 static char ERROR_FLAG[6][20] = {
"NONE",
"ERROR",
"WARNING",
"NOTICE",
"INFO",
"DEBUG"};
46 static void _HMI_LOG(
enum LOG_LEVEL level,
const char* file,
const char* func,
const int line,
const char* prefix,
const char* log, ...)
48 const int log_level = (getenv(
"USE_HMI_DEBUG") == NULL)?
LOG_LEVEL_ERROR:atoi(getenv(
"USE_HMI_DEBUG"));
58 clock_gettime(CLOCK_REALTIME, &tp);
59 time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
63 if (log == NULL || vasprintf(&message, log, args) < 0)
65 fprintf(stderr,
"[%10.3f] [%s %s] [%s, %s(), Line:%d] >>> %s \n", time / 1000.0, prefix,
ERROR_FLAG[level], file, func, line, message);
70 #endif //__HMI_DEBUG_H__
static void _HMI_LOG(enum LOG_LEVEL level, const char *file, const char *func, const int line, const char *prefix, const char *log,...)
static char ERROR_FLAG[6][20]