use super::*;
#[tokio::test]
async fn test20027_the_daemon_log_reaches_the_stream_pages_read() {
let (tx, ring) = wsb::logging::log_stream();
let mut live = tx.subscribe();
let marker = format!("daemon-subscriber-marker-{}", std::process::id());
tracing::subscriber::with_default(subscriber(false), || tracing::info!("{marker}"));
let quiet = format!("{marker}-debug");
tracing::subscriber::with_default(subscriber(false), || tracing::debug!("{quiet}"));
let line = tokio::time::timeout(std::time::Duration::from_secs(5), async {
loop {
let line = live.recv().await.expect("the stream delivers the daemon's line");
if line.message == marker {
break line;
}
}
})
.await
.expect("the daemon's line never reached the stream");
assert_eq!(line.level, "INFO");
let history = ring.snapshot().await;
assert!(history.iter().any(|line| line.message == marker));
assert!(
!history.iter().any(|line| line.message == quiet),
"a debug line reached the panel of a daemon started without --debug"
);
}