Skip to content

Commit

Permalink
Allow passing an ID to journald log driver
Browse files Browse the repository at this point in the history
The ID has been dropped before this patch, but we can use it to refer a
container ID or anything else identifiable.

Signed-off-by: Sascha Grunert <[email protected]>
  • Loading branch information
saschagrunert committed Sep 3, 2024
1 parent de76947 commit 8d4208d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libcrun/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ libcrun_init_logging (crun_output_handler *new_output_handler, void **new_output

case LOG_TYPE_JOURNALD:
*new_output_handler = log_write_to_journald;
*new_output_handler_arg = NULL;
*new_output_handler_arg = (void *) id;
break;
}
}
Expand Down Expand Up @@ -310,7 +310,7 @@ log_write_to_syslog (int errno_, const char *msg, int verbosity, void *arg arg_u
}

void
log_write_to_journald (int errno_, const char *msg, int verbosity, void *arg arg_unused)
log_write_to_journald (int errno_, const char *msg, int verbosity, void *id)
{
(void) errno_;
(void) msg;
Expand All @@ -330,10 +330,10 @@ log_write_to_journald (int errno_, const char *msg, int verbosity, void *arg arg
break;
}
if (errno_ == 0)
sd_journal_send ("PRIORITY=%d", priority, "MESSAGE=%s", msg, "ID=%s", arg, NULL);
sd_journal_send ("PRIORITY=%d", priority, "MESSAGE=%s", msg, "ID=%s", id, NULL);
else
sd_journal_send ("PRIORITY=%d", priority, "MESSAGE=%s: %s", msg, strerror (errno_), "ID=%s",
arg, NULL);
id, NULL);
#endif
}

Expand Down

0 comments on commit 8d4208d

Please sign in to comment.