]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/journal/journal-file.c
journal: emit debug log about settings only once (or when changed)
[thirdparty/systemd.git] / src / journal / journal-file.c
index c38c3e7c14f3f04a825d46741bdbb56d6bded63e..f0dd695adbce74983ca838c1b241a45e9ce7e436 100644 (file)
 #include "chattr-util.h"
 #include "compress.h"
 #include "fd-util.h"
+#include "format-util.h"
 #include "fs-util.h"
 #include "journal-authenticate.h"
 #include "journal-def.h"
 #include "journal-file.h"
 #include "lookup3.h"
 #include "memory-util.h"
-#include "parse-util.h"
 #include "path-util.h"
 #include "random-util.h"
 #include "set.h"
@@ -340,7 +340,8 @@ bool journal_file_is_offlining(JournalFile *f) {
 }
 
 JournalFile* journal_file_close(JournalFile *f) {
-        assert(f);
+        if (!f)
+                return NULL;
 
 #if HAVE_GCRYPT
         /* Write the final tag */
@@ -3184,7 +3185,6 @@ int journal_file_open(
         JournalFile *f;
         void *h;
         int r;
-        char bytes[FORMAT_BYTES_MAX];
 
         assert(ret);
         assert(fd >= 0 || fname);
@@ -3220,9 +3220,23 @@ int journal_file_open(
 #endif
         };
 
-        log_debug("Journal effective settings seal=%s compress=%s compress_threshold_bytes=%s",
-                  yes_no(f->seal), yes_no(JOURNAL_FILE_COMPRESS(f)),
-                  format_bytes(bytes, sizeof(bytes), f->compress_threshold_bytes));
+        if (DEBUG_LOGGING) {
+                static int last_seal = -1, last_compress = -1;
+                static uint64_t last_bytes = UINT64_MAX;
+                char bytes[FORMAT_BYTES_MAX];
+
+                if (last_seal != f->seal ||
+                    last_compress != JOURNAL_FILE_COMPRESS(f) ||
+                    last_bytes != f->compress_threshold_bytes) {
+
+                        log_debug("Journal effective settings seal=%s compress=%s compress_threshold_bytes=%s",
+                                  yes_no(f->seal), yes_no(JOURNAL_FILE_COMPRESS(f)),
+                                  format_bytes(bytes, sizeof bytes, f->compress_threshold_bytes));
+                        last_seal = f->seal;
+                        last_compress = JOURNAL_FILE_COMPRESS(f);
+                        last_bytes = f->compress_threshold_bytes;
+                }
+        }
 
         if (mmap_cache)
                 f->mmap = mmap_cache_ref(mmap_cache);