{
char message[1024];
cec_log_level level;
+ int64_t time;
} cec_log_message;
typedef struct cec_keypress
m_controller->AddLog(CEC_LOG_DEBUG, "command sent");
- CCondition::Sleep((uint32_t) data.size * (uint32_t)24 /*data*/ + (uint32_t)5 /*start bit (4.5 ms)*/ + (uint32_t)50 /* to be on the safe side */);
+ CCondition::Sleep((uint32_t) data.size * (uint32_t)24 /*data*/ + (uint32_t)5 /*start bit (4.5 ms)*/);
}
return true;
using namespace CEC;
CLibCEC::CLibCEC(const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */, uint16_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */) :
+ m_iStartTime(GetTimeMs()),
m_iCurrentButton(CEC_USER_CONTROL_CODE_UNKNOWN),
m_buttontime(0)
{
{
cec_log_message message;
message.level = level;
+ message.time = GetTimeMs() - m_iStartTime;
snprintf(message.message, sizeof(message.message), "%s", strMessage.c_str());
m_logBuffer.Push(message);
}
virtual void SetCurrentButton(cec_user_control_code iButtonCode);
protected:
+ int64_t m_iStartTime;
cec_user_control_code m_iCurrentButton;
int64_t m_buttontime;
CCECProcessor *m_cec;
*/
#include <stdint.h>
-#include <time.h>
+#include <sys/time.h>
namespace CEC
{
}
return -1;
#else
- struct timespec time;
- clock_gettime(CLOCK_MONOTONIC, &time);
-
- return ((int64_t)time.tv_sec * (int64_t)1000) + (int64_t)time.tv_nsec / (int64_t)1000;
+ timeval time;
+ gettimeofday(&time, NULL);
+ return (int64_t) (time.tv_sec * 1000 + time.tv_usec / 1000);
#endif
}
switch (message.level)
{
case CEC_LOG_ERROR:
- cout << "ERROR: " << message.message << endl;
+ cout << "ERROR: ";
break;
case CEC_LOG_WARNING:
- cout << "WARNING: " << message.message << endl;
+ cout << "WARNING: ";
break;
case CEC_LOG_NOTICE:
- cout << "NOTICE: " << message.message << endl;
+ cout << "NOTICE: ";
break;
case CEC_LOG_DEBUG:
- cout << "DEBUG: " << message.message << endl;
+ cout << "DEBUG: ";
break;
}
+
+ CStdString strMessageTmp;
+ strMessageTmp.Format("[%16lld]\t%s", message.time, message.message);
+ cout << strMessageTmp.c_str() << endl;
}
}