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) ...@@ -509,12 +509,15 @@ int logInit (void)
for (int i = 0; i < MAX_LOG_PREDEF_COMPONENTS; i++) for (int i = 0; i < MAX_LOG_PREDEF_COMPONENTS; i++)
register_log_component(comp_name[i], comp_extension[i], 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"; g_log->filelog_name = "/tmp/openair.log";
log_getconfig(g_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 // 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++) { for (int i=MAX_LOG_PREDEF_COMPONENTS; i < MAX_LOG_COMPONENTS; i++) {
memset(&(g_log->log_component[i]),0,sizeof(log_component_t)); memset(&(g_log->log_component[i]),0,sizeof(log_component_t));
...@@ -592,15 +595,17 @@ static inline int log_header(log_component_t *c, ...@@ -592,15 +595,17 @@ static inline int log_header(log_component_t *c,
} else { } else {
threadIdString[0] = 0; threadIdString[0] = 0;
} }
return snprintf(log_buffer, buffsize, "%s%s%s[%s] %c %s%s",
flag & FLAG_NOCOLOR ? "" : log_level_highlight_start[level], return snprintf(log_buffer,
timeString, buffsize,
threadIdString, "%s%s%s[%s]%s%s%s",
c->name, flag & FLAG_NOCOLOR ? "" : log_level_highlight_start[level],
flag & FLAG_LEVEL ? g_log->level2string[level] : ' ', timeString,
l, threadIdString,
threadname c->name,
); g_log->level2string[level], // will print space if no level selected
l,
threadname);
} }
void logRecord_mt(const char *file, void logRecord_mt(const char *file,
......
...@@ -217,7 +217,7 @@ typedef struct { ...@@ -217,7 +217,7 @@ typedef struct {
typedef struct { typedef struct {
log_component_t log_component[MAX_LOG_COMPONENTS]; log_component_t log_component[MAX_LOG_COMPONENTS];
log_component_back_t log_rarely_used[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; int flag;
char *filelog_name; char *filelog_name;
debug_flags_t debug_mask; 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