From: Lars Op den Kamp Date: Thu, 27 Oct 2011 22:00:39 +0000 (+0200) Subject: cec: introduced CEC_LOG_TRAFFIC log level and log all traffic in that level X-Git-Tag: upstream/2.2.0~1^2~207 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1d3ca3def5ca5f6e53ef02b3ce311e27ea9da93f;p=deb_libcec.git cec: introduced CEC_LOG_TRAFFIC log level and log all traffic in that level --- diff --git a/include/cectypes.h b/include/cectypes.h index 941b542..4c029e8 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -530,6 +530,7 @@ typedef enum cec_opcode typedef enum cec_log_level { CEC_LOG_DEBUG = 0, + CEC_LOG_TRAFFIC, CEC_LOG_NOTICE, CEC_LOG_WARNING, CEC_LOG_ERROR diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 648ec20..468d981 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -186,13 +186,12 @@ bool CCECProcessor::SetInactiveView(void) void CCECProcessor::LogOutput(const cec_command &data) { - CStdString txStr = "transmit "; - txStr.AppendFormat(" %02x", ((uint8_t)data.initiator << 4) + (uint8_t)data.destination); - txStr.AppendFormat(":%02x", (uint8_t)data.opcode); + CStdString strTx; + strTx.Format("<< %02x:%02x", ((uint8_t)data.initiator << 4) + (uint8_t)data.destination, (uint8_t)data.opcode); for (uint8_t iPtr = 0; iPtr < data.parameters.size; iPtr++) - txStr.AppendFormat(":%02x", data.parameters[iPtr]); - m_controller->AddLog(CEC_LOG_DEBUG, txStr.c_str()); + strTx.AppendFormat(":%02x", data.parameters[iPtr]); + m_controller->AddLog(CEC_LOG_TRAFFIC, strTx.c_str()); } bool CCECProcessor::Transmit(const cec_command &data, bool bWaitForAck /* = true */) @@ -543,10 +542,10 @@ void CCECProcessor::ParseVendorId(cec_logical_address device, const cec_datapack void CCECProcessor::ParseCommand(cec_command &command) { CStdString dataStr; - dataStr.Format(">> received frame: %1x%1x:%02x", command.initiator, command.destination, command.opcode); + dataStr.Format(">> %1x%1x:%02x", command.initiator, command.destination, command.opcode); for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++) dataStr.AppendFormat(":%02x", (unsigned int)command.parameters[iPtr]); - m_controller->AddLog(CEC_LOG_DEBUG, dataStr.c_str()); + m_controller->AddLog(CEC_LOG_TRAFFIC, dataStr.c_str()); if (!m_bMonitor) m_busDevices[(uint8_t)command.initiator]->HandleCommand(command); diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index b13f446..8ca3faa 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -115,6 +115,9 @@ void flush_log(ICECAdapter *cecParser) case CEC_LOG_NOTICE: cout << "NOTICE: "; break; + case CEC_LOG_TRAFFIC: + cout << "TRAFFIC: "; + break; case CEC_LOG_DEBUG: cout << "DEBUG: "; break;