chiark / gitweb /
test: hook up more tests with make check
[elogind.git] / src / journal / journalctl.c
index 4c975d3e7c49c3b6c1bcea5df70918f1e86b23c5..65b3bd5a86f44abd31fd152b35dbb75702a71a33 100644 (file)
@@ -225,7 +225,9 @@ static int add_matches(sd_journal *j, char **args) {
 
         STRV_FOREACH(i, args) {
 
-                if (path_is_absolute(*i)) {
+                if (streq(*i, "+"))
+                        r = sd_journal_add_disjunction(j);
+                else if (path_is_absolute(*i)) {
                         char *p;
                         const char *path;
                         struct stat st;
@@ -249,7 +251,7 @@ static int add_matches(sd_journal *j, char **args) {
                                         return -ENOMEM;
                                 }
 
-                                r = sd_journal_add_match(j, t, strlen(t));
+                                r = sd_journal_add_match(j, t, 0);
                                 free(t);
                         } else {
                                 free(p);
@@ -259,10 +261,10 @@ static int add_matches(sd_journal *j, char **args) {
 
                         free(p);
                 } else
-                        r = sd_journal_add_match(j, *i, strlen(*i));
+                        r = sd_journal_add_match(j, *i, 0);
 
                 if (r < 0) {
-                        log_error("Failed to add match: %s", strerror(-r));
+                        log_error("Failed to add match '%s': %s", *i, strerror(-r));
                         return r;
                 }
         }
@@ -299,6 +301,8 @@ int main(int argc, char *argv[]) {
         sd_journal *j = NULL;
         unsigned line = 0;
         bool need_seek = false;
+        sd_id128_t previous_boot_id;
+        bool previous_boot_id_valid = false;
 
         log_parse_environment();
         log_open();
@@ -390,6 +394,8 @@ int main(int argc, char *argv[]) {
 
         for (;;) {
                 for (;;) {
+                        sd_id128_t boot_id;
+
                         if (need_seek) {
                                 r = sd_journal_next(j);
                                 if (r < 0) {
@@ -401,6 +407,16 @@ int main(int argc, char *argv[]) {
                         if (r == 0)
                                 break;
 
+                        r = sd_journal_get_monotonic_usec(j, NULL, &boot_id);
+                        if (r >= 0) {
+                                if (previous_boot_id_valid &&
+                                    !sd_id128_equal(boot_id, previous_boot_id))
+                                        printf(ANSI_HIGHLIGHT_ON "----- Reboot -----" ANSI_HIGHLIGHT_OFF "\n");
+
+                                previous_boot_id = boot_id;
+                                previous_boot_id_valid = true;
+                        }
+
                         line ++;
 
                         r = output_journal(j, arg_output, line, 0, arg_show_all);