37 #include "ccec/Util.hpp"
40 #define MAX_LOG_BUFF 500
43 #define __TIMESTAMP() do { \
45 struct timeval __tv; \
46 gettimeofday(&__tv, NULL); \
47 localtime_r(&__tv.tv_sec, &__tm); \
48 printf("\r\n%02d%02d%02d-%02d:%02d:%02d:%06d ", \
49 __tm.tm_year+1900-2000, \
58 static const char *logLevel[][2] =
79 const int buffer_length = 256;
80 char cecBuffer[buffer_length];
81 memset(&st,0,
sizeof(st));
82 if(0 == stat(
"/tmp/cec_log_enabled",&st))
84 if(!S_ISREG(st.st_mode))
88 if((fp = fopen(
"/tmp/cec_log_enabled",
"r")) == NULL)
90 printf(
"Error in opening cec_log_enabled filee \n");
93 if ((fgets(cecBuffer,buffer_length,fp)) != NULL)
95 for (
int i =0; i< LOG_MAX;i++)
97 if (strncmp(cecBuffer,logLevel[i][0],strlen(logLevel[i][0])) == 0)
99 cec_log_level = atoi(logLevel[i][1]);
109 char _CEC_LOG_PREFIX[64];
122 if ((level < LOG_MAX) && (level <= cec_log_level))
124 char tmp_buff[MAX_LOG_BUFF];
126 va_start(args, format);
127 vsnprintf(tmp_buff,MAX_LOG_BUFF-1,format, args);
129 __TIMESTAMP();printf(
"[%s]%s", _CEC_LOG_PREFIX, tmp_buff);
144 if((cec_log_level < LOG_MAX) && (cec_log_level >= LOG_DEBUG))
146 for (
int ii = 0; ii < len; ii++) {
147 printf(
"%02X ", buf[ii]);