Skip to main content

LogQuery

Struct LogQuery 

Source
pub struct LogQuery<'a> { /* private fields */ }
Expand description

Builder for configuring and executing log queries from indexed journal files.

This builder allows you to specify:

  • Direction (forward/backward in time)
  • Anchor timestamp (starting point)
  • Limit (maximum entries to retrieve)
  • Source timestamp field (which field to use for timestamps)
  • Filter (to match specific entries)

§Example

use journal_index::{Anchor, Direction};
use journal_function::logs::LogQuery;

let entries = LogQuery::new(&file_indexes, Anchor::Head, Direction::Forward)
    .with_limit(100)
    .execute();

Implementations§

Source§

impl<'a> LogQuery<'a>

Source

pub fn new( file_indexes: &'a [FileIndex], anchor: Anchor, direction: Direction, ) -> Self

Create a new log query builder with required parameters.

§Arguments
  • file_indexes - Journal file indexes to query
  • anchor - Starting point for the query (Head, Tail, or specific timestamp)
  • direction - Direction to iterate (Forward or Backward)
§Optional Configuration

Use builder methods to set optional parameters:

  • Limit: None (unlimited)
  • Source timestamp field: _SOURCE_REALTIME_TIMESTAMP
  • Filter: None
Source

pub fn with_limit(self, limit: usize) -> Self

Set the maximum number of log entries to retrieve (optional).

If not set (None), all matching entries will be retrieved.

Source

pub fn with_source_timestamp_field(self, field: Option<FieldName>) -> Self

Set the source timestamp field to use for entry timestamps (optional).

Pass None to use the entry’s realtime timestamp from the journal header. Pass Some(field_name) to use a custom timestamp field from the entry data.

Source

pub fn with_filter(self, filter: Filter) -> Self

Set a filter to apply to log entries (optional).

Only entries matching the filter will be included in the results.

Source

pub fn with_after_usec(self, after: u64) -> Self

Set the lower time boundary (inclusive) in microseconds (optional).

Only entries with timestamp >= after_usec will be included. This enforces a hard boundary regardless of anchor or limit.

Source

pub fn with_before_usec(self, before: u64) -> Self

Set the upper time boundary (exclusive) in microseconds (optional).

Only entries with timestamp < before_usec will be included. This enforces a hard boundary regardless of anchor or limit.

Source

pub fn with_regex(self, pattern: impl Into<String>) -> Self

Set a regex pattern for full-text search (optional).

Only entries where at least one data object (in “FIELD=value” format) matches the regex will be included in the results.

The pattern will be compiled when the query is executed. Invalid patterns will cause execute() to return an error.

Source

pub fn with_cancellation(self, token: CancellationToken) -> Self

Set a cancellation token for the query (optional).

When set, the query will check the token before processing each file and return early with partial results if cancelled.

Source

pub fn with_progress(self, counter: Arc<AtomicUsize>) -> Self

Set a progress counter for the query (optional).

When set, the counter is incremented (via fetch_add) after each file is processed in retrieve_log_entries.

Source

pub fn with_output_fields<I, S>(self, fields: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Limit returned field-value pairs to the requested on-disk field names.

Source

pub fn execute(self) -> Result<Vec<LogEntryData>>

Execute the query and return log entries.

This consumes the builder and returns a vector of log entries sorted by timestamp according to the configured direction.

§Errors

Returns an error if anchor or direction were not set, or if time boundaries are invalid.

Source

pub fn execute_page( self, state: Option<&PaginationState>, ) -> Result<(Vec<LogEntryData>, PaginationState)>

Execute the query with pagination support.

This consumes the builder and returns a page of log entries along with pagination state that can be used to retrieve the next page.

§Arguments
  • state - Optional pagination state from a previous query. Pass None for the first page.
§Returns

Returns a tuple of (log entry data, new pagination state). If the pagination state is empty (no file positions tracked), there are no more results.

§Errors

Returns an error if anchor or direction were not set, or if time boundaries are invalid.

Auto Trait Implementations§

§

impl<'a> Freeze for LogQuery<'a>

§

impl<'a> RefUnwindSafe for LogQuery<'a>

§

impl<'a> Send for LogQuery<'a>

§

impl<'a> Sync for LogQuery<'a>

§

impl<'a> Unpin for LogQuery<'a>

§

impl<'a> UnsafeUnpin for LogQuery<'a>

§

impl<'a> UnwindSafe for LogQuery<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scope for T

Source§

fn with<F, R>(self, f: F) -> R
where Self: Sized, F: FnOnce(Self) -> R,

Scoped with ownership.
Source§

fn with_ref<F, R>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Scoped with reference.
Source§

fn with_mut<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Scoped with mutable reference.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Value for T
where T: Send + Sync + 'static,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more