Commit 7f570191 authored by Robert Schmidt's avatar Robert Schmidt

log: Only print one space if no level selected

Prior to this change, when no "level" option is given to the logging
module, we see

    [PHY]   RU 0 RF started cpu_meas_enabled 0
    [HW]   No connected device, generating void samples...

with three spaces, which is too much. This change reduces the amount of
spaces to 1 without log level.
Co-authored-by: default avatarRobert Schmidt <robert.schmidt@openairinterface.org>
parent 090cf00c
......@@ -509,12 +509,15 @@ int logInit (void)
for (int i = 0; i < MAX_LOG_PREDEF_COMPONENTS; i++)
register_log_component(comp_name[i], comp_extension[i], i);
for (int i=0 ; log_level_names[i].name != NULL ; i++)
g_log->level2string[i] = toupper(log_level_names[i].name[0]); // uppercased first letter of level name
g_log->filelog_name = "/tmp/openair.log";
log_getconfig(g_log);
for (int i = 0; log_level_names[i].name != NULL; i++)
if (g_log->flag & FLAG_LEVEL)
snprintf(g_log->level2string[i], sizeof g_log->level2string[i], " %c ", toupper(log_level_names[i].name[0]));
else
snprintf(g_log->level2string[i], sizeof g_log->level2string[i], " ");
// set all unused component items to 0, they are for non predefined components
for (int i=MAX_LOG_PREDEF_COMPONENTS; i < MAX_LOG_COMPONENTS; i++) {
memset(&(g_log->log_component[i]),0,sizeof(log_component_t));
......@@ -592,15 +595,17 @@ static inline int log_header(log_component_t *c,
} else {
threadIdString[0] = 0;
}
return snprintf(log_buffer, buffsize, "%s%s%s[%s] %c %s%s",
flag & FLAG_NOCOLOR ? "" : log_level_highlight_start[level],
timeString,
threadIdString,
c->name,
flag & FLAG_LEVEL ? g_log->level2string[level] : ' ',
l,
threadname
);
return snprintf(log_buffer,
buffsize,
"%s%s%s[%s]%s%s%s",
flag & FLAG_NOCOLOR ? "" : log_level_highlight_start[level],
timeString,
threadIdString,
c->name,
g_log->level2string[level], // will print space if no level selected
l,
threadname);
}
void logRecord_mt(const char *file,
......
......@@ -217,7 +217,7 @@ typedef struct {
typedef struct {
log_component_t log_component[MAX_LOG_COMPONENTS];
log_component_back_t log_rarely_used[MAX_LOG_COMPONENTS];
char level2string[NUM_LOG_LEVEL];
char level2string[NUM_LOG_LEVEL][4];
int flag;
char *filelog_name;
debug_flags_t debug_mask;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment