Minor changes to log

master
Ismael Gomez 7 years ago
parent 37ee5505e9
commit dfda8edc04

@ -54,6 +54,12 @@ static const char log_level_text[LOG_LEVEL_N_ITEMS][16] = {"None ",
"Info ",
"Debug "};
static const char log_level_text_short[LOG_LEVEL_N_ITEMS][16] = {"[-]",
"[E]",
"[W]",
"[I]",
"[D]"};
class log
{
public:
@ -100,6 +106,12 @@ public:
int get_hex_limit() {
return hex_limit;
}
void set_log_level_short(bool enable) {
level_text_short = enable;
}
void show_layer(bool enable) {
show_layer_en = enable;
}
// Pure virtual methods for logging
virtual void console(std::string message, ...) = 0;
@ -121,6 +133,8 @@ protected:
int hex_limit;
std::string service_name;
bool show_layer_en;
bool level_text_short;
bool add_string_en;
std::string add_string_val;
};

@ -137,7 +137,9 @@ SRSLTE_API srslte_dci_format_t srslte_dci_format_from_string(char *str);
SRSLTE_API char* srslte_dci_format_string(srslte_dci_format_t format);
SRSLTE_API int srslte_dci_location_set(srslte_dci_location_t *c,
SRSLTE_API char* srslte_dci_format_string_short(srslte_dci_format_t format);
SRSLTE_API int srslte_dci_location_set(srslte_dci_location_t *c,
uint32_t L,
uint32_t nCCE);

@ -67,8 +67,14 @@ void log_filter::all_log(srslte::LOG_LEVEL_ENUM level,
std::stringstream ss;
ss << now_time() << " ";
ss << "[" <<get_service_name() << "] ";
ss << log_level_text[level] << " ";
if (show_layer_en) {
ss << "[" <<get_service_name() << "] ";
}
if (level_text_short) {
ss << log_level_text_short[level] << " ";
} else {
ss << log_level_text[level] << " ";
}
if(do_tti) {
ss << "[" << std::setfill('0') << std::setw(5) << tti << "] ";
}
@ -92,8 +98,14 @@ void log_filter::all_log(srslte::LOG_LEVEL_ENUM level,
std::stringstream ss;
ss << now_time() << " ";
ss << "[" <<get_service_name() << "] ";
ss << log_level_text[level] << " ";
if (show_layer_en) {
ss << "[" <<get_service_name() << "] ";
}
if (level_text_short) {
ss << log_level_text_short[level] << " ";
} else {
ss << log_level_text[level] << " ";
}
if(do_tti) {
ss << "[" << std::setfill('0') << std::setw(5) << tti << "] ";

@ -366,14 +366,14 @@ uint32_t srslte_dci_dl_info(char *info_str, uint32_t len, srslte_ra_dl_dci_t *dc
switch(dci_msg->alloc_type) {
case SRSLTE_RA_ALLOC_TYPE0:
n += snprintf(&info_str[n], len-n, "ra_type0={rbg_mask=0x%x}, ", dci_msg->type0_alloc.rbg_bitmask);
n += snprintf(&info_str[n], len-n, "type0={rbg=0x%x}, ", dci_msg->type0_alloc.rbg_bitmask);
break;
case SRSLTE_RA_ALLOC_TYPE1:
n += snprintf(&info_str[n], len-n, "ra_type1={vrb_mask=0x%x, rbg_subset=%d, shift=%d}, ",
n += snprintf(&info_str[n], len-n, "type1={vrb=0x%x, rbg_s=%d, sh=%d}, ",
dci_msg->type1_alloc.vrb_bitmask, dci_msg->type1_alloc.rbg_subset, dci_msg->type1_alloc.shift);
break;
case SRSLTE_RA_ALLOC_TYPE2:
n += snprintf(&info_str[n], len-n, "ra_type2={riv=0x%x, rb=(%d,%d), mode=%s",
n += snprintf(&info_str[n], len-n, "type2={riv=%d, rb=(%d,%d), mode=%s",
dci_msg->type2_alloc.riv,
dci_msg->type2_alloc.RB_start, dci_msg->type2_alloc.RB_start+dci_msg->type2_alloc.L_crb-1,
dci_msg->type2_alloc.mode==SRSLTE_RA_TYPE2_LOC?"local":"dist");
@ -388,17 +388,17 @@ uint32_t srslte_dci_dl_info(char *info_str, uint32_t len, srslte_ra_dl_dci_t *dc
n += snprintf(&info_str[n], len-n, "pid=%d, ", dci_msg->harq_process);
if (dci_msg->tb_en[0]) {
n += snprintf(&info_str[n], len-n, "CW0={mcs=%d, rv=%d, ndi=%d}, ", dci_msg->mcs_idx, dci_msg->rv_idx, dci_msg->ndi);
n += snprintf(&info_str[n], len-n, "TB0={mcs=%d, rv=%d, ndi=%d}, ", dci_msg->mcs_idx, dci_msg->rv_idx, dci_msg->ndi);
}
if (dci_msg->tb_en[1]) {
n += snprintf(&info_str[n], len-n, "CW1={mcs=%d, rv=%d, ndi=%d}, ", dci_msg->mcs_idx_1, dci_msg->rv_idx_1, dci_msg->ndi_1);
n += snprintf(&info_str[n], len-n, "TB1={mcs=%d, rv=%d, ndi=%d}, ", dci_msg->mcs_idx_1, dci_msg->rv_idx_1, dci_msg->ndi_1);
}
if (format == SRSLTE_DCI_FORMAT1 || format == SRSLTE_DCI_FORMAT1A || format == SRSLTE_DCI_FORMAT1B) {
n += snprintf(&info_str[n], len-n, "tpc_pucch=%d, ", dci_msg->tpc_pucch);
}
if (format == SRSLTE_DCI_FORMAT2 || format == SRSLTE_DCI_FORMAT2A || format == SRSLTE_DCI_FORMAT2B) {
n += snprintf(&info_str[n], len-n, "tb_swap=%d, pinfo=%d", dci_msg->tb_cw_swap, dci_msg->pinfo);
n += snprintf(&info_str[n], len-n, "tb_sw=%d, pinfo=%d", dci_msg->tb_cw_swap, dci_msg->pinfo);
}
return n;
}
@ -407,19 +407,19 @@ uint32_t srslte_dci_ul_info(char *info_str, uint32_t len, srslte_ra_ul_dci_t *dc
{
int n = 0;
n += snprintf(&info_str[n], len-n, "riv=0x%x, rb=(%d,%d), ", dci_msg->type2_alloc.riv,
n += snprintf(&info_str[n], len-n, "riv=%d, rb=(%d,%d), ", dci_msg->type2_alloc.riv,
dci_msg->type2_alloc.RB_start, dci_msg->type2_alloc.RB_start+dci_msg->type2_alloc.L_crb-1);
switch(dci_msg->freq_hop_fl) {
case SRSLTE_RA_PUSCH_HOP_DISABLED:
n += snprintf(&info_str[n], len-n, "freq_hop=n/a, ");
n += snprintf(&info_str[n], len-n, "f_h=n/a, ");
break;
default:
n += snprintf(&info_str[n], len-n, "freq_hop=%d, ", dci_msg->freq_hop_fl);
n += snprintf(&info_str[n], len-n, "f_h=%d, ", dci_msg->freq_hop_fl);
break;
}
n += snprintf(&info_str[n], len-n, "mcs=%d, rv=%d, ndi=%d, ", dci_msg->mcs_idx, dci_msg->rv_idx, dci_msg->ndi);
n += snprintf(&info_str[n], len-n, "tpc_pusch=%d, dmrs_cs=%d, cqi_req=%s",
n += snprintf(&info_str[n], len-n, "tpc_pusch=%d, dmrs_cs=%d, cqi=%s",
dci_msg->tpc_pusch, dci_msg->n_dmrs, dci_msg->cqi_request?"yes":"no");
return n;
@ -1367,6 +1367,32 @@ char* srslte_dci_format_string(srslte_dci_format_t format) {
}
}
char* srslte_dci_format_string_short(srslte_dci_format_t format) {
switch (format) {
case SRSLTE_DCI_FORMAT0:
return " 0";
case SRSLTE_DCI_FORMAT1:
return " 1";
case SRSLTE_DCI_FORMAT1A:
return "1A";
case SRSLTE_DCI_FORMAT1B:
return "1B";
case SRSLTE_DCI_FORMAT1C:
return "1C";
case SRSLTE_DCI_FORMAT1D:
return "1D";
case SRSLTE_DCI_FORMAT2:
return " 2";
case SRSLTE_DCI_FORMAT2A:
return "2A";
case SRSLTE_DCI_FORMAT2B:
return "2B";
default:
return "N/A"; // fatal error
}
}
void srslte_dci_msg_type_fprint(FILE *f, srslte_dci_msg_type_t type) {
switch (type.type) {
case SRSLTE_DCI_MSG_TYPE_PUSCH_SCHED:

Loading…
Cancel
Save