#![cfg(feature = "timestamp")]
mod helpers; use helpers::*;
use rustlog::{info};
#[test]
#[cfg(all(feature = "timestamp", not(feature = "localtime")))]
fn utc_timestamp_prefix() {
let _g = test_lock().lock().unwrap();
let (buf, _guard) = attach_mem_sink();
reset_runtime();
rustlog::set_show_time(true);
info!("ts");
let s = String::from_utf8(buf.lock().unwrap().clone()).unwrap();
let line = s.lines().next().unwrap_or("");
assert!(line.contains("Z "), "expected UTC 'Z ' marker before level: {line}");
let year: i32 = line
.get(0..4)
.and_then(|s| s.parse().ok())
.unwrap_or_default();
assert!(
(1970..=2100).contains(&year),
"unexpected year prefix (bad timestamp date conversion?): {line}"
);
}
#[cfg(feature = "localtime")]
#[test]
fn localtime_timestamp_prefix() {
let _g = test_lock().lock().unwrap();
let (buf, _guard) = attach_mem_sink();
reset_runtime();
rustlog::set_show_time(true);
info!("ts");
let s = String::from_utf8(buf.lock().unwrap().clone()).unwrap();
let line = s.lines().next().unwrap_or("");
assert!(!line.contains("Z "), "localtime should not include 'Z ': {line}");
}