summaryrefslogtreecommitdiff
path: root/src/journal/sd-journal.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-06-09 10:32:38 +0200
committerLennart Poettering <lennart@poettering.net>2012-06-17 00:03:12 +0200
commit089842938dd0f4080084044bb9a1a3b00137926a (patch)
treeba0e7b04ac312b2f29ee8f3fd99d8c0ed353a5b9 /src/journal/sd-journal.c
parent8db4213e7b38ebc54bfdc7215991cc23b9580e3a (diff)
journal: expose and make use of cutoff times of journal
This helps explaining when the log output of "systemctl status" is incomplete because the logs got rotated since the service was started.
Diffstat (limited to 'src/journal/sd-journal.c')
-rw-r--r--src/journal/sd-journal.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 9f46f5c6aa..5ed8c3f7a5 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1620,6 +1620,81 @@ _public_ int sd_journal_process(sd_journal *j) {
}
}
+_public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from, uint64_t *to) {
+ Iterator i;
+ JournalFile *f;
+ bool first = true;
+ int r;
+
+ if (!j)
+ return -EINVAL;
+ if (!from && !to)
+ return -EINVAL;
+
+ HASHMAP_FOREACH(f, j->files, i) {
+ usec_t fr, t;
+
+ r = journal_file_get_cutoff_realtime_usec(f, &fr, &t);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ continue;
+
+ if (first) {
+ if (from)
+ *from = fr;
+ if (to)
+ *to = t;
+ first = false;
+ } else {
+ if (from)
+ *from = MIN(fr, *from);
+ if (to)
+ *to = MIN(t, *to);
+ }
+ }
+
+ return first ? 0 : 1;
+}
+
+_public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot_id, uint64_t *from, uint64_t *to) {
+ Iterator i;
+ JournalFile *f;
+ bool first = true;
+ int r;
+
+ if (!j)
+ return -EINVAL;
+ if (!from && !to)
+ return -EINVAL;
+
+ HASHMAP_FOREACH(f, j->files, i) {
+ usec_t fr, t;
+
+ r = journal_file_get_cutoff_monotonic_usec(f, boot_id, &fr, &t);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ continue;
+
+ if (first) {
+ if (from)
+ *from = fr;
+ if (to)
+ *to = t;
+ first = false;
+ } else {
+ if (from)
+ *from = MIN(fr, *from);
+ if (to)
+ *to = MIN(t, *to);
+ }
+ }
+
+ return first ? 0 : 1;
+}
+
+
/* _public_ int sd_journal_query_unique(sd_journal *j, const char *field) { */
/* if (!j) */
/* return -EINVAL; */