Struct systemd::journal::Journal [−][src]
#[repr(transparent)]pub struct Journal(_);
Expand description
A reader for systemd journal.
Supports read, next, previous, and seek operations.
Note that the Journal
is not Send
nor Sync
: it cannot be used in any thread other
than the one which creates it.
Implementations
👎 Deprecated since 0.8.0: Use OpenOptions
instead. It removes the blind boolean options, and allows complete specification of the selected/filtered files
Use OpenOptions
instead. It removes the blind boolean options, and allows complete specification of the selected/filtered files
Open a Journal
corresponding to files
for reading
If the calling process doesn’t have permission to read the system journal, a call to
Journal::open
with System
or All
will succeed, but system journal entries won’t be
included. This behavior is due to systemd.
If runtime_only
is true, include only journal entries from the current boot. If false,
include all entries.
If local_only
is true, include only journal entries originating from localhost. If false,
include all entries.
Methods from Deref<Target = JournalRef>
Returns a file descriptor a file descriptor that may be asynchronously polled in an external event loop and is signaled as soon as the journal changes, because new entries or files were added, rotation took place, or files have been deleted, and similar. The file descriptor is suitable for usage in poll(2).
This corresponds to sd_journal_get_fd
Fields that are longer that this number of bytes may be truncated when retrieved by this Journal
instance.
Use [set_data_threshold()
] to adjust.
Set the number of bytes after which returned fields may be truncated when retrieved by
this Journal
instance.
Setting this as small as possible for your application can allow the library to avoid decompressing large objects in full.
pub fn get_data<A: CStrArgument>(
&mut self,
field: A
) -> Result<Option<JournalEntryField<'_>>>
pub fn get_data<A: CStrArgument>(
&mut self,
field: A
) -> Result<Option<JournalEntryField<'_>>>
Get the data associated with a particular field from the current journal entry
Note that this may be affected by the current data threshold, see data_threshold()
and
set_data_threshold()
.
Note: the use of &mut
here is because calls to some (though not all) other journal
functions can invalidate the reference returned within JournalEntryField
. In particular:
any other obtaining of data (enumerate, etc) or any adjustment of the read pointer
(seeking, etc) invalidates the returned reference.
Corresponds to sd_journal_get_data()
.
Restart the iteration done by [enumerate_data()
] and [enumerate_avaliable_data()
] over
fields of the current entry.
Corresponds to sd_journal_restart_data()
Obtain the next data
Corresponds to sd_journal_enumerate_data()
Obtain a display-able that display’s the current entrie’s fields
Iterate over journal entries.
Corresponds to sd_journal_next()
Iterate over journal entries, skipping skip_count
of them
Corresponds to sd_journal_next_skip()
Iterate in reverse over journal entries
Corresponds to sd_journal_previous()
Iterate in reverse over journal entries, skipping skip_count
of them.
Corresponds to sd_journal_previous_skip()
Read the next entry from the journal. Returns Ok(None)
if there
are no more entries to read.
Read the previous entry from the journal. Returns Ok(None)
if there
are no more entries to read.
Wait for next entry to arrive.
Using a wait_time
of None
will wait for an unlimited period for new entries.
Corresponds to sd_journal_wait()
.
pub fn await_next_entry(
&mut self,
wait_time: Option<Duration>
) -> Result<Option<JournalRecord>>
pub fn await_next_entry(
&mut self,
wait_time: Option<Duration>
) -> Result<Option<JournalRecord>>
Wait for the next entry to appear. Returns Ok(None)
if there were no
new entries in the given wait time.
Pass wait_time None
to wait for an unlimited period for new entries.
pub fn watch_all_elements<F>(&mut self, f: F) -> Result<()> where
F: FnMut(JournalRecord) -> Result<()>,
pub fn watch_all_elements<F>(&mut self, f: F) -> Result<()> where
F: FnMut(JournalRecord) -> Result<()>,
Iterate through all elements from the current cursor, then await the next entry(s) and wait again.
Corresponds to sd_journal_seek_monotonic_usec()
Corresponds to sd_journal_seek_realtime_usec()
Corresponds to sd_journal_seek_cursor()
Seek to a specific position in journal using a general JournalSeek
Note: after seeking, this Journal
does not refer to any entry (and consequently can not
obtain information about an entry, like [cursor()
], etc). Use the iteration functions
([next()
], [previous()
], [next_skip()
], and [previous_skip()
]) to move onto an
entry.
Test if a given cursor matches the current postition in the journal
Corresponds to sd_journal_test_cursor()
.
Returns timestamp at which current journal entry was recorded.
Returns monotonic timestamp and boot ID at which current journal entry was recorded.
Returns monotonic timestamp at which current journal entry was recorded. Returns an error if the current entry is not from the current system boot.
Adds a match by which to filter the entries of the journal. If a match is applied, only entries with this field set will be iterated.
Inserts a disjunction (i.e. logical OR) in the match list.
Inserts a conjunction (i.e. logical AND) in the match list.
Flushes all matches, disjunction and conjunction terms. After this call all filtering is removed and all entries in the journal will be iterated again.
Trait Implementations
Performs the conversion.
Performs the conversion.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
type Target = JournalRef
type Target = JournalRef
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
type CType = sd_journal
type CType = sd_journal
The raw C type.
type Ref = JournalRef
type Ref = JournalRef
The type representing a reference to this type.
Constructs an instance of this type from its raw type.
Returns a raw pointer to the wrapped value.