summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/logs-show.c33
-rw-r--r--src/shared/logs-show.h2
2 files changed, 35 insertions, 0 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 116dc8a36c..79a977c156 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -931,6 +931,33 @@ int add_matches_for_user_unit(sd_journal *j, const char *unit, uid_t uid) {
return r;
}
+int add_match_this_boot(sd_journal *j) {
+ char match[9+32+1] = "_BOOT_ID=";
+ sd_id128_t boot_id;
+ int r;
+
+ assert(j);
+
+ r = sd_id128_get_boot(&boot_id);
+ if (r < 0) {
+ log_error("Failed to get boot id: %s", strerror(-r));
+ return r;
+ }
+
+ sd_id128_to_string(boot_id, match + 9);
+ r = sd_journal_add_match(j, match, strlen(match));
+ if (r < 0) {
+ log_error("Failed to add match: %s", strerror(-r));
+ return r;
+ }
+
+ r = sd_journal_add_conjunction(j);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
int show_journal_by_unit(
FILE *f,
const char *unit,
@@ -957,6 +984,10 @@ int show_journal_by_unit(
if (r < 0)
return r;
+ r = add_match_this_boot(j);
+ if (r < 0)
+ return r;
+
if (system)
r = add_matches_for_unit(j, unit);
else
@@ -964,6 +995,8 @@ int show_journal_by_unit(
if (r < 0)
return r;
+ log_debug("Journal filter: %s", journal_make_match_string(j));
+
r = show_journal(f, j, mode, n_columns, not_before, how_many, flags);
if (r < 0)
return r;
diff --git a/src/shared/logs-show.h b/src/shared/logs-show.h
index b0f93a661a..c9a9ad3e91 100644
--- a/src/shared/logs-show.h
+++ b/src/shared/logs-show.h
@@ -37,6 +37,8 @@ int output_journal(
unsigned n_columns,
OutputFlags flags);
+int add_match_this_boot(sd_journal *j);
+
int add_matches_for_unit(
sd_journal *j,
const char *unit);