chiark / gitweb /
update TODO
[elogind.git] / src / shared / logs-show.c
index fedb4532db2505ea5b1bdf385ad312fcf152ded5..697b5cf4b734c58e848114e0b2ca45beec2670e5 100644 (file)
@@ -551,10 +551,11 @@ int show_journal_by_unit(
                 usec_t not_before,
                 unsigned how_many,
                 bool show_all,
-                bool follow) {
+                bool follow,
+                bool warn_cutoff) {
 
         char *m = NULL;
-        sd_journal *j;
+        sd_journal *j = NULL;
         int r;
         int fd;
         unsigned line = 0;
@@ -639,6 +640,26 @@ int show_journal_by_unit(
                                 goto finish;
                 }
 
+                if (warn_cutoff && line < how_many && not_before > 0) {
+                        sd_id128_t boot_id;
+                        usec_t cutoff;
+
+                        /* Check whether the cutoff line is too early */
+
+                        r = sd_id128_get_boot(&boot_id);
+                        if (r < 0)
+                                goto finish;
+
+                        r = sd_journal_get_cutoff_monotonic_usec(j, boot_id, &cutoff, NULL);
+                        if (r < 0)
+                                goto finish;
+
+                        if (not_before < cutoff)
+                                printf("Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.\n");
+
+                        warn_cutoff = false;
+                }
+
                 if (!follow)
                         break;