pub struct Log { /* private fields */ }Expand description
Tracks rotation state for size and count limits.
Implementations§
Source§impl Log
impl Log
pub fn new_with_lifecycle_observer( path: &Path, config: Config, observer: Arc<dyn LogLifecycleObserver>, ) -> Result<Log, WriterError>
pub fn new_with_hooks( path: &Path, config: Config, observer: Option<Arc<dyn LogLifecycleObserver>>, artifact_sizer: Option<Arc<dyn LogArtifactSizer>>, ) -> Result<Log, WriterError>
pub fn with_lifecycle_observer( self, observer: Arc<dyn LogLifecycleObserver>, ) -> Log
pub fn with_artifact_sizer(self, sizer: Arc<dyn LogArtifactSizer>) -> Log
Sourcepub fn write_entry(
&mut self,
items: &[&[u8]],
source_realtime_usec: Option<u64>,
) -> Result<(), WriterError>
👎Deprecated since 0.7.2: use write_entry_with_timestamps and provide an explicit entry monotonic timestamp
pub fn write_entry( &mut self, items: &[&[u8]], source_realtime_usec: Option<u64>, ) -> Result<(), WriterError>
use write_entry_with_timestamps and provide an explicit entry monotonic timestamp
Writes a journal entry.
This compatibility method always returns an error under the strict
writer contract. Use Log::write_entry_with_timestamps and provide
an explicit entry monotonic timestamp.
Sourcepub fn write_entry_with_timestamps(
&mut self,
items: &[&[u8]],
timestamps: EntryTimestamps,
) -> Result<(), WriterError>
pub fn write_entry_with_timestamps( &mut self, items: &[&[u8]], timestamps: EntryTimestamps, ) -> Result<(), WriterError>
Writes a journal entry with optional source and entry timestamp overrides.
Overrides are safe by construction:
- entry realtime is clamped to strict monotonic progression (
last + 1usfloor) - entry monotonic is also clamped to strict monotonic progression (
last + 1usfloor)
Sourcepub fn write_fields(
&mut self,
fields: &[StructuredField<'_>],
source_realtime_usec: Option<u64>,
) -> Result<(), WriterError>
👎Deprecated since 0.7.2: use write_fields_with_timestamps and provide an explicit entry monotonic timestamp
pub fn write_fields( &mut self, fields: &[StructuredField<'_>], source_realtime_usec: Option<u64>, ) -> Result<(), WriterError>
use write_fields_with_timestamps and provide an explicit entry monotonic timestamp
Writes a journal entry from structured field names and binary-safe values.
This is the preferred path when the producer already has split field
names and values. If source_realtime_usec is provided, a
_SOURCE_REALTIME_TIMESTAMP field is added.
This compatibility method always returns an error under the strict
writer contract. Use Log::write_fields_with_timestamps and provide
an explicit entry monotonic timestamp.
Sourcepub fn write_fields_with_timestamps(
&mut self,
fields: &[StructuredField<'_>],
timestamps: EntryTimestamps,
) -> Result<(), WriterError>
pub fn write_fields_with_timestamps( &mut self, fields: &[StructuredField<'_>], timestamps: EntryTimestamps, ) -> Result<(), WriterError>
Writes structured fields with optional source and entry timestamp overrides.
Entry monotonic timestamp is required. Entry realtime and monotonic
overrides use the same clamping rules as
Log::write_entry_with_timestamps.
Sourcepub fn write_fields_with_options(
&mut self,
fields: &[StructuredField<'_>],
timestamps: EntryTimestamps,
options: EntryWriteOptions,
) -> Result<(), WriterError>
pub fn write_fields_with_options( &mut self, fields: &[StructuredField<'_>], timestamps: EntryTimestamps, options: EntryWriteOptions, ) -> Result<(), WriterError>
Writes structured fields with explicit low-level entry write options.
Use this only when the caller can satisfy any invariants required by the
selected EntryWriteOptions, especially no duplicate full KEY=value
payloads when trusted_unique_payloads is enabled.
Sourcepub fn sync(&mut self) -> Result<(), WriterError>
pub fn sync(&mut self) -> Result<(), WriterError>
Syncs all written data to disk, ensuring durability.
This should be called after writing a batch of log entries to ensure they are persisted to disk before acknowledging the request.
Sourcepub fn close(self) -> Result<(), WriterError>
pub fn close(self) -> Result<(), WriterError>
Archives and closes the active file.
In strict systemd naming mode this renames <source>.journal to the
chain filename before retention, matching the explicit close behavior of
the other SDK implementations. Drop remains best-effort for callers
that do not explicitly close.
pub fn active_file(&self) -> Option<&File>
pub fn active_path(&self) -> Option<&Path>
pub fn configured_directory(&self) -> &Path
pub fn journal_directory(&self) -> &Path
pub fn machine_id(&self) -> Uuid
pub fn boot_id(&self) -> Uuid
pub fn source(&self) -> &Source
Sourcepub fn enforce_retention(&mut self) -> Result<(), WriterError>
pub fn enforce_retention(&mut self) -> Result<(), WriterError>
Applies the configured retention policy without requiring a rotation or close. The current active file is counted in retention envelopes and is protected from deletion.