Expand description
Test utilities for downstream crates that depend on rlg.
use rlg_test::{assert_logged, capture, LogExt};
use rlg::log::Log;
use rlg::log_level::LogLevel;
let capture = capture();
Log::info("user authenticated")
.component("auth")
.with("user_id", 42_u64)
.log_to(&capture);
assert_logged!(capture, level == LogLevel::INFO);
assert_logged!(capture, contains "authenticated");
assert_logged!(capture, attribute "user_id" => 42_u64);Two patterns are supported:
-
Capture handle (
capture) — explicitly route records into the handle via thelog_toextension method orcapture.push(). Works regardless of the global engine state. -
Global capture (not implemented in v0.0.11) — install the handle as the engine’s sink for the test scope. Tracked under the v0.0.12 roadmap; deferred so this crate doesn’t reach into
rlg’s engine internals.
Macros§
- assert_
logged - One-stop assertion macro for verifying that a
Capturehandle observed a record matching some predicate.
Structs§
- Capture
- In-memory sink that captures every record routed to it.
Traits§
Functions§
- attribute_
eq - Did
capturesee at least one record whosekeyattribute equalsexpected? - capture
- Shortcut for
Capture::new(). Reads more naturally at call sites:let capture = rlg_test::capture();. - description_
contains - Did
capturesee at least one record whosedescriptioncontainsneedle? - has_
component - Did
capturesee at least one record whosecomponentmatches? - has_
level - Did
capturesee at least one record with the given level?