Commit ea1aa382 authored by Robert Schmidt's avatar Robert Schmidt

Update log header format to improve visual alignment

The new format left-aligns the component name and enforces a minimum width
of 7 (log component) characters, padding shorter names with spaces after
the closing "]".

Example output:

    [14:05:43.395376] [E1AP]   I releasing UE 1
    [14:05:43.395400] [GTPU]   I [91] UE ID 1: Delete all tunnels (1 tunnels)
    [14:05:43.395414] [NR_RRC] A [DL] (cellID bc614e, UE ID 1 RNTI 8e27) Send RRC Release
    [14:05:43.395431] [RRC]    I UE 1: received bearer release complete
    [14:05:43.424551] [RLC]    W Remove UE 36391
    [14:05:43.424597] [NR_RRC] I removed UE CU UE ID 1/RNTI 8e27
    [14:05:43.424773] [NR_RRC] A [--] (cellID bc614e, UE ID 1 RNTI 8e27) Remove UE context
    [14:05:43.425205] [NR_MAC] I Remove NR rnti 0x8e27
    [14:05:43.582158] [HW]     W Lost socket
    ^C
    ** Caught SIGTERM, shutting down
    Returned from ITTI signal handler
    [14:05:43.948721] [GNB_APP] I stopping nr-softmodem
    [14:05:43.948746] [PHY]    I Killing gNB 0 processing threads
    [14:05:44.574818] [PHY]    I Stopping RU 0 processing threads
    [14:05:44.575000] [PHY]    I RU 0 RF device stopped
    [14:05:44.575006] [GNB_APP] I turned off RU rfdevice
parent 7f570191
......@@ -461,9 +461,15 @@ int register_log_component(const char *name, const char *fext, int compidx)
}
if (computed_compidx >= 0 && computed_compidx <MAX_LOG_COMPONENTS) {
g_log->log_component[computed_compidx].name = strdup(name);
g_log->log_component[computed_compidx].stream = stdout;
g_log->log_component[computed_compidx].filelog = 0;
log_component_t *c = &g_log->log_component[computed_compidx];
c->name = strdup(name);
int n = snprintf(c->headerName, sizeof(c->headerName), "[%s", c->name);
if (n >= sizeof(c->headerName) - 1) // snprintf() truncated
n = sizeof(c->headerName) - 2;
c->headerName[n] = ']';
c->headerName[n + 1] = 0;
c->stream = stdout;
c->filelog = 0;
g_log->log_rarely_used[computed_compidx].filelog_name = calloc(1, strlen(name) + 16); /* /tmp/<name>.%s */
sprintf(g_log->log_rarely_used[computed_compidx].filelog_name, "/tmp/%s.", name);
strncat(g_log->log_rarely_used[computed_compidx].filelog_name, fext, 3);
......@@ -598,11 +604,11 @@ static inline int log_header(log_component_t *c,
return snprintf(log_buffer,
buffsize,
"%s%s%s[%s]%s%s%s",
"%s%s%s%-8s%s%s%s",
flag & FLAG_NOCOLOR ? "" : log_level_highlight_start[level],
timeString,
threadIdString,
c->name,
c->headerName,
g_log->level2string[level], // will print space if no level selected
l,
threadname);
......
......@@ -206,6 +206,7 @@ typedef struct {
typedef struct {
const char *name;
char headerName[19];
int level;
int filelog;
FILE *stream;
......
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