@cryptotaxi247 / netdata-1 / commits / a5c8d88d7

set journal path for logging (#16457)

Costa Tsaousis committed Nov 22, 2023 at 19:41 UTC a5c8d88d78c6203c43011524176c1111647a8622
1 file changed +11 -3
libnetdata/log/log.c
+11 -3
@@ -364,6 +364,7 @@ static struct {
364 struct {
365 bool initialized;
366 int fd;
367 + char filename[FILENAME_MAX + 1];
368 } journal_direct;
369
370 struct {
@@ -675,9 +676,16 @@ static bool nd_log_journal_systemd_init(void) {
676 return nd_log.journal.initialized;
677 }
678
679 +static void nd_log_journal_direct_set_env(void) {
680 + if(nd_log.sources[NDLS_COLLECTORS].method == NDLO_JOURNAL)
681 + setenv("NETDATA_SYSTEMD_JOURNAL_PATH", nd_log.journal_direct.filename, 1);
682 +}
683 +
684 static bool nd_log_journal_direct_init(const char *path) {
679 - if(nd_log.journal_direct.initialized)
685 + if(nd_log.journal_direct.initialized) {
686 + nd_log_journal_direct_set_env();
687 return true;
688 + }
689
690 char filename[FILENAME_MAX + 1];
691 if(!is_path_unix_socket(path)) {
@@ -704,8 +712,8 @@ static bool nd_log_journal_direct_init(const char *path) {
712 nd_log.journal_direct.fd = fd;
713 nd_log.journal_direct.initialized = true;
714
707 - if(nd_log.sources[NDLS_COLLECTORS].method == NDLO_JOURNAL)
708 - setenv("NETDATA_SYSTEMD_JOURNAL_PATH", filename, 1);
715 + strncpyz(nd_log.journal_direct.filename, filename, sizeof(nd_log.journal_direct.filename) - 1);
716 + nd_log_journal_direct_set_env();
717
718 return true;
719 }