-
Notifications
You must be signed in to change notification settings - Fork 131
Add container labels to JournalD logs #553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: OZoneGuy <[email protected]>
08aa60a
to
84675f1
Compare
Signed-off-by: OZoneGuy <[email protected]>
pass NULL as the first argument for subsequent calls Signed-off-by: OZoneGuy <[email protected]>
8a1db71
to
53f81bd
Compare
container_labels = g_alloca((sizeof(char *)) * container_labels_count); | ||
container_labels_lengths = g_alloca((sizeof(int *)) * container_labels_count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when are these ever going to be freed? In this way they are just leaked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to create them once in at the beginning of the program lifecycle and reuse them. I will look into freeing them at the at exit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is fine, could you just add an inline comment saying it is by design?
} | ||
container_labels = g_alloca((sizeof(char *)) * container_labels_count); | ||
container_labels_lengths = g_alloca((sizeof(int *)) * container_labels_count); | ||
char *pair = strtok(log_labels, ","); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strtok
modifies the buffer, so log_labels
will be modified. The correct way to do it is to g_strdup
the string before passing it to strtok
.
if (writev_buffer_append_segment_no_flush(&bufv, container_labels[i], container_labels_lengths[i]) < 0) | ||
return -1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to not create the arrays before and then have to worry about cleaning them up.
Just strdup container_labels here and call writev_buffer_append_segment_no_flush
while you parse it.
Add the ability to add the container labels to the journald logs as extra parameters.
Relies on the caller to pass the label key and value.
Usage:
The labels and values will be added to the journald entry.
This is my first contribution to a C codebase. Feedback is most
Still need to test the changes locally.