Skip to content

Commit

Permalink
journald: print tag and name if both are specified
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hunt <[email protected]>
  • Loading branch information
haircommander committed Apr 14, 2022
1 parent f134a29 commit 81086b7
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/ctr_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,23 @@ void configure_log_drivers(gchar **log_drivers, int64_t log_size_max_, char *cuu
/* Setup some sd_journal_sendv arguments that won't change */
container_id_full = g_strdup_printf("CONTAINER_ID_FULL=%s", cuuid);
container_id = g_strdup_printf("CONTAINER_ID=%s", short_cuuid);
if (tag) {
container_tag = g_strdup_printf("CONTAINER_TAG=%s", tag);
container_tag_len = strlen(container_tag);

syslog_identifier = g_strdup_printf("SYSLOG_IDENTIFIER=%s", tag);
syslog_identifier_len = strlen(syslog_identifier);
} else if (name) {
/* save the length so we don't have to compute every sd_journal_* call */
/* Priority order of syslog_identifier (in order of precedence) is tag, name, `conmon`. */
syslog_identifier = g_strdup_printf("SYSLOG_IDENTIFIER=%s", short_cuuid);
syslog_identifier_len = TRUNC_ID_LEN + SYSLOG_IDENTIFIER_EQ_LEN;
if (name) {
name_len = strlen(name);
container_name = g_strdup_printf("CONTAINER_NAME=%s", name);

syslog_identifier = g_strdup_printf("SYSLOG_IDENTIFIER=%s", name);
syslog_identifier_len = name_len + SYSLOG_IDENTIFIER_EQ_LEN;
} else {
syslog_identifier = g_strdup_printf("SYSLOG_IDENTIFIER=%s", short_cuuid);
syslog_identifier_len = TRUNC_ID_LEN + SYSLOG_IDENTIFIER_EQ_LEN;
}
if (tag) {
container_tag = g_strdup_printf("CONTAINER_TAG=%s", tag);
container_tag_len = strlen(container_tag);

syslog_identifier = g_strdup_printf("SYSLOG_IDENTIFIER=%s", tag);
syslog_identifier_len = strlen(syslog_identifier);
}
}
}
Expand Down

0 comments on commit 81086b7

Please sign in to comment.