Struct merino_integration_tests::utils::logging::LogWatcher
source · [−]Expand description
Helper to collect events emitted by Tracing and later make assertions about the collected events.
Fields
buf: Arc<Mutex<Vec<u8>>>The raw bytes received from Tracing. Should represent new-line separated JSON objects.
events: Vec<TracingJsonEvent>Events serialized from buf. As valid JSON objects are
parsed from buf, the corresponding bytes are removed from buf. This
way if there are any partial writes, only the complete objects are
processed from the buffer, leaving incomplete objects in place.
Implementations
sourceimpl LogWatcher
impl LogWatcher
sourcepub fn with_events(events: Vec<TracingJsonEvent>) -> Self
pub fn with_events(events: Vec<TracingJsonEvent>) -> Self
Make a new LogWatcher with some events pre-populated. Primarily for testing LogWatcher itself.
sourcepub fn events(&mut self) -> Iter<'_, TracingJsonEvent>
pub fn events(&mut self) -> Iter<'_, TracingJsonEvent>
Iterate over the events collected so far by this log watcher.
sourcepub fn has<F>(&mut self, predicate: F) -> bool where
F: FnMut(&TracingJsonEvent) -> bool,
pub fn has<F>(&mut self, predicate: F) -> bool where
F: FnMut(&TracingJsonEvent) -> bool,
Test if any event this logger received matches predicate.
Example
// assert!(log_watcher.has(|msg| msg.field_contains("message", "request success")));sourcefn convert_events(&mut self)
fn convert_events(&mut self)
Iterate through self.buf to convert newline separated, completed JSON
objects into TracingJsonEvent instances that are placed in
self.events.
Trait Implementations
sourceimpl Default for LogWatcher
impl Default for LogWatcher
sourcefn default() -> LogWatcher
fn default() -> LogWatcher
Returns the “default value” for a type. Read more
sourceimpl MakeWriter for LogWatcher
impl MakeWriter for LogWatcher
type Writer = LogWatcherWriter
type Writer = LogWatcherWriter
The concrete io::Write implementation returned by make_writer. Read more
sourcefn make_writer(&self) -> Self::Writer
fn make_writer(&self) -> Self::Writer
Auto Trait Implementations
impl RefUnwindSafe for LogWatcher
impl Send for LogWatcher
impl Sync for LogWatcher
impl Unpin for LogWatcher
impl UnwindSafe for LogWatcher
Blanket Implementations
sourceimpl<'a, T, E> AsTaggedExplicit<'a, E> for T where
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for T where
T: 'a,
sourceimpl<'a, T, E> AsTaggedImplicit<'a, E> for T where
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for T where
T: 'a,
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<M> MakeWriterExt for M where
M: MakeWriter,
impl<M> MakeWriterExt for M where
M: MakeWriter,
sourcefn with_max_level(self, level: Level) -> WithMaxLevel<Self>
fn with_max_level(self, level: Level) -> WithMaxLevel<Self>
Wraps self and returns a MakeWriter that will only write output
for events at or below the provided verbosity Level. For instance,
Level::TRACE is considered to be _more verbosethanLevel::INFO`. Read more
sourcefn with_min_level(self, level: Level) -> WithMinLevel<Self>
fn with_min_level(self, level: Level) -> WithMinLevel<Self>
Wraps self and returns a MakeWriter that will only write output
for events at or above the provided verbosity Level. Read more
sourcefn with_filter<F>(self, filter: F) -> WithFilter<Self, F> where
F: Fn(&Metadata<'_>) -> bool,
fn with_filter<F>(self, filter: F) -> WithFilter<Self, F> where
F: Fn(&Metadata<'_>) -> bool,
Wraps self with a predicate that takes a span or event’s Metadata
and returns a bool. The returned MakeWriter’s
MakeWriter::make_writer_for method will check the predicate to
determine if a writer should be produced for a given span or event. Read more
sourcefn and<B>(self, other: B) -> Tee<Self, B> where
B: MakeWriter,
fn and<B>(self, other: B) -> Tee<Self, B> where
B: MakeWriter,
Combines self with another type implementing MakeWriter, returning
a new MakeWriter that produces [writers] that write to both
outputs. Read more
sourcefn or_else<W, B>(self, other: B) -> OrElse<Self, B> where
Self: MakeWriter<Writer = EitherWriter<W, Sink>>,
B: MakeWriter,
W: Write,
fn or_else<W, B>(self, other: B) -> OrElse<Self, B> where
Self: MakeWriter<Writer = EitherWriter<W, Sink>>,
B: MakeWriter,
W: Write,
Combines self with another type implementing MakeWriter, returning
a new MakeWriter that calls other’s [make_writer] if self’s
make_writer returns OptionalWriter::none. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more