Skip to main content

Crate rlg_test

Crate rlg_test 

Source
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:

  1. Capture handle (capture) — explicitly route records into the handle via the log_to extension method or capture.push(). Works regardless of the global engine state.

  2. 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 Capture handle observed a record matching some predicate.

Structs§

Capture
In-memory sink that captures every record routed to it.

Traits§

LogExt
Extension trait that routes a Log entry into a Capture handle in-place of the global engine.

Functions§

attribute_eq
Did capture see at least one record whose key attribute equals expected?
capture
Shortcut for Capture::new(). Reads more naturally at call sites: let capture = rlg_test::capture();.
description_contains
Did capture see at least one record whose description contains needle?
has_component
Did capture see at least one record whose component matches?
has_level
Did capture see at least one record with the given level?