assign msg-type to temp variable before logging ASN1 message in RRC

This commit is contained in:
Andre Puschmann 2019-11-27 13:38:45 +01:00
parent 5d63b493b6
commit 365cb2dfe2
2 changed files with 14 additions and 9 deletions

View File

@ -160,15 +160,15 @@ template <class T>
void rrc::log_rrc_message(const std::string& source, const direction_t dir, const srslte::byte_buffer_t* pdu,
const T& msg)
{
const char* msg_type = msg.msg.c1().type().to_string().c_str();
if (rrc_log->get_level() == srslte::LOG_LEVEL_INFO) {
rrc_log->info("%s - %s %s (%d B)\n", source.c_str(), dir == Tx ? "Tx" : "Rx",
msg.msg.c1().type().to_string().c_str(), pdu->N_bytes);
rrc_log->info("%s - %s %s (%d B)\n", source.c_str(), dir == Tx ? "Tx" : "Rx", msg_type, pdu->N_bytes);
} else if (rrc_log->get_level() >= srslte::LOG_LEVEL_DEBUG) {
asn1::json_writer json_writer;
msg.to_json(json_writer);
rrc_log->debug_hex(pdu->msg, pdu->N_bytes, "%s - %s %s (%d B)\n", source.c_str(), dir == Tx ? "Tx" : "Rx",
msg.msg.c1().type().to_string().c_str(), pdu->N_bytes);
rrc_log->debug("Content:\n%s\n", json_writer.to_string().c_str());
rrc_log->debug_hex(
pdu->msg, pdu->N_bytes, "%s - %s %s (%d B)\n", source.c_str(), dir == Tx ? "Tx" : "Rx", msg_type, pdu->N_bytes);
rrc_log->debug_long("Content:\n%s\n", json_writer.to_string().c_str());
}
}

View File

@ -78,14 +78,19 @@ void rrc::srslte_rrc_log(const char* str)
template <class T>
void rrc::log_rrc_message(const std::string source, const direction_t dir, const byte_buffer_t* pdu, const T& msg)
{
const char* msg_type = msg.msg.c1().type().to_string().c_str();
if (rrc_log->get_level() == srslte::LOG_LEVEL_INFO) {
rrc_log->info("%s - %s %s (%d B)\n", source.c_str(), (dir == Rx) ? "Rx" : "Tx",
msg.msg.c1().type().to_string().c_str(), pdu->N_bytes);
rrc_log->info("%s - %s %s (%d B)\n", source.c_str(), (dir == Rx) ? "Rx" : "Tx", msg_type, pdu->N_bytes);
} else if (rrc_log->get_level() >= srslte::LOG_LEVEL_DEBUG) {
asn1::json_writer json_writer;
msg.to_json(json_writer);
rrc_log->debug_hex(pdu->msg, pdu->N_bytes, "%s - %s %s (%d B)\n", source.c_str(), (dir == Rx) ? "Rx" : "Tx",
msg.msg.c1().type().to_string().c_str(), pdu->N_bytes);
rrc_log->debug_hex(pdu->msg,
pdu->N_bytes,
"%s - %s %s (%d B)\n",
source.c_str(),
(dir == Rx) ? "Rx" : "Tx",
msg_type,
pdu->N_bytes);
rrc_log->debug_long("Content:\n%s\n", json_writer.to_string().c_str());
}
}