Skip to content

Commit 55ca496

Browse files
committed
Use consistent timestamps in tests
1 parent 1e13ea5 commit 55ca496

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

test/test-manager/src/logging.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct LoggerInner {
1919

2020
struct StoredRecord {
2121
level: log::Level,
22-
time: chrono::DateTime<chrono::Local>,
22+
time: chrono::DateTime<chrono::Utc>,
2323
mod_path: String,
2424
text: String,
2525
}
@@ -70,7 +70,12 @@ impl Logger {
7070
for stored_record in std::mem::take(&mut inner.stored_records) {
7171
println!(
7272
"[{} {} {}] {}",
73-
stored_record.time, stored_record.level, stored_record.mod_path, stored_record.text
73+
stored_record
74+
.time
75+
.to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
76+
stored_record.level,
77+
stored_record.mod_path,
78+
stored_record.text
7479
);
7580
}
7681
}
@@ -99,7 +104,7 @@ impl log::Log for Logger {
99104
let mod_path = record.module_path().unwrap_or("");
100105
inner.stored_records.push(StoredRecord {
101106
level: record.level(),
102-
time: chrono::Local::now(),
107+
time: chrono::Utc::now(),
103108
mod_path: mod_path.to_owned(),
104109
text: record.args().to_string(),
105110
});
@@ -193,7 +198,11 @@ impl TestResult {
193198

194199
macro_rules! println_with_time {
195200
($fmt:tt$(, $($args:tt)*)?) => {
196-
println!(concat!("[{}] ", $fmt), chrono::Local::now(), $($($args)*)?)
201+
println!(
202+
concat!("[{}] ", $fmt),
203+
chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
204+
$($($args)*)?
205+
)
197206
};
198207
}
199208

0 commit comments

Comments
 (0)