Expand description
§qjournal
Cross-platform native implementation of the systemd-journald binary journal format.
This library can read and write .journal files that are fully compatible with
journalctl --file=<path>, without depending on libsystemd.
§Quick Start
use qjournal::JournalWriter;
use std::path::Path;
let mut writer = JournalWriter::open(Path::new("/tmp/test.journal")).unwrap();
writer.append_entry(&[
("MESSAGE", b"Hello, world!" as &[u8]),
("PRIORITY", b"6"),
("SYSLOG_IDENTIFIER", b"myapp"),
]).unwrap();
writer.flush().unwrap();§Reading
use qjournal::JournalReader;
use std::path::Path;
let mut reader = JournalReader::open(Path::new("/tmp/test.journal")).unwrap();
for entry in reader.entries().unwrap() {
if let Some(msg) = entry.get(b"MESSAGE") {
println!("{}", String::from_utf8_lossy(msg));
}
}Re-exports§
pub use error::Error;pub use error::Result;pub use reader::JournalReader;pub use verify::journal_file_verify;pub use verify::VerifyResult;pub use writer::Compression;pub use writer::JournalMetrics;pub use writer::JournalWriter;pub use writer::compression_default;pub use writer::compression_requested;pub use writer::journal_file_dispose;pub use writer::journal_file_parse_uid_from_filename;pub use writer::journal_metrics_equal;pub use writer::journal_reset_metrics;
Modules§
- def
- Binary on-disk layout definitions, ported from systemd’s
journal-def.h. - error
- Error types for qjournal operations.
- hash
- Jenkins’ lookup3 hash algorithm, ported from systemd’s
lookup3.c/lookup3.h. - mmap_
cache - Simplified mmap cache for read-only journal file access.
- reader
- Journal file reader.
- verify
- Journal file verification.
- writer
- Journal file writer.