diff --git a/lib/include/srslte/common/log.h b/lib/include/srslte/common/log.h index 22a74c611..0bb876446 100644 --- a/lib/include/srslte/common/log.h +++ b/lib/include/srslte/common/log.h @@ -134,6 +134,7 @@ public: virtual void warning(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0; virtual void info(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0; virtual void debug(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0; + virtual void debug_long(const char* message, ...) __attribute__((format(printf, 2, 3))) = 0; // Same with hex dump virtual void error_hex(const uint8_t *, int, const char *, ...) __attribute__((format (printf, 4, 5))) diff --git a/lib/src/common/log_filter.cc b/lib/src/common/log_filter.cc index 712589c65..058a1b4fe 100644 --- a/lib/src/common/log_filter.cc +++ b/lib/src/common/log_filter.cc @@ -68,15 +68,15 @@ void log_filter::init(std::string layer, logger *logger_, bool tti) void log_filter::all_log( srslte::LOG_LEVEL_ENUM level, uint32_t tti, const char* msg, const uint8_t* hex, int size, bool long_msg) { - char buffer_tti[16]; - char buffer_time[64]; + char buffer_tti[16] = {}; + char buffer_time[64] = {}; if (logger_h) { logger::unique_log_str_t log_str = nullptr; if (long_msg) { // For long messages, dynamically allocate a new log_str with enough size outside the pool. - uint32_t log_str_msg_len = sizeof(buffer_tti) + sizeof(buffer_time) + 10 + strlen(msg); + uint32_t log_str_msg_len = sizeof(buffer_tti) + sizeof(buffer_time) + 20 + size; log_str = logger::unique_log_str_t(new logger::log_str(nullptr, log_str_msg_len), logger::log_str_deleter()); } else { log_str = logger_h->allocate_unique_log_str(); @@ -164,7 +164,7 @@ void log_filter::debug_long(const char* message, ...) va_list args; va_start(args, message); if (vasprintf(&args_msg, message, args) > 0) - all_log(LOG_LEVEL_ERROR, tti, args_msg); + all_log(LOG_LEVEL_DEBUG, tti, args_msg, nullptr, strlen(args_msg), true); va_end(args); free(args_msg); } diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index 03292a83a..958cf110b 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -107,7 +107,7 @@ void rrc::log_rrc_message(const std::string source, const direction_t dir, const 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("Content:\n%s\n", json_writer.to_string().c_str()); + rrc_log->debug_long("Content:\n%s\n", json_writer.to_string().c_str()); } }