[systemd-devel] odd seek_tail behaviour
Daurnimator
quae at daurnimator.com
Sun Oct 12 22:27:22 PDT 2014
Hi All,
I was trying to write a program that tailed the journal, but found that
sd_journal_seek_tail() didn't work as expected.
That is: that it would seek to the last/most recent thing in the journal,
and I could tail things from there.
I whipped up a quick demonstration program, that shows that messages I
'next' through, are before the 'cutoff':
#include <stdio.h>
#include <assert.h>
#include "systemd/sd-journal.h"
int main() {
sd_journal* j;
assert(sd_journal_open(&j, 0)==0);
uint64_t from, to;
assert(sd_journal_get_cutoff_realtime_usec(j, &from, &to)==1);
printf("CUTOFF = %llu\n", to);
printf("TAIL = %d\n", sd_journal_seek_tail(j));
for (int i=0; i<10; i++) {
printf("NEXT = %lld\n", sd_journal_next(j));
assert(sd_journal_get_realtime_usec(j, &from)==0);
printf("FOUND from %llu\n", from);
}
return 0;
}
Compiled with: gcc -std=c99 tail_logs.c -l systemd
Example output:
CUTOFF = 1413177397982789
TAIL = 0
NEXT = 1
FOUND from 1400437372012374
NEXT = 1
FOUND from 1400438753925868
NEXT = 1
FOUND from 1400438753926192
NEXT = 1
FOUND from 1400438753926257
NEXT = 1
FOUND from 1400438753926289
NEXT = 1
FOUND from 1400438753926309
NEXT = 1
FOUND from 1400438753926330
NEXT = 1
FOUND from 1400438753926353
NEXT = 1
FOUND from 1400438753926373
NEXT = 1
FOUND from 1400438753926395
Is this behaviour expected? I'm using systemd 216.
Regards,
Daurn.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20141013/f42e62b4/attachment.html>
More information about the systemd-devel
mailing list