Skip to content

Commit

Permalink
file-logger: Don't log <> if ike_name is disabled and no IKE_SA is av…
Browse files Browse the repository at this point in the history
…ailable

Fixes: a2fba6d ("file-logger: Add option to log messages as JSON objects")
  • Loading branch information
tobiasbrunner committed Dec 3, 2024
1 parent 832c811 commit bea1f11
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/libcharon/bus/listeners/file_logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ METHOD(logger_t, log_, void,
ike_sa_t* ike_sa, const char *message)
{
char groupstr[5], timestr[128];
char idstr[11] = "", namestr[128] = "", nameidstr[142];
char idstr[11] = "", namestr[128] = "", nameidstr[142] = "";
const char *current = message, *next = NULL;
struct tm tm;
timeval_t tv;
Expand Down Expand Up @@ -199,8 +199,11 @@ METHOD(logger_t, log_, void,
{
snprintf(groupstr, sizeof(groupstr), "%N", debug_names, group);
}
snprintf(nameidstr, sizeof(nameidstr), " <%s%s%s>", namestr,
namestr[0] ? "|" : "", idstr);
if (idstr[0])
{
snprintf(nameidstr, sizeof(nameidstr), " <%s%s%s>", namestr,
namestr[0] ? "|" : "", idstr);
}
/* prepend the prefix in front of every line */
while (TRUE)
{
Expand Down

0 comments on commit bea1f11

Please sign in to comment.