mirror of
https://seed.radicle.dev/rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE.git
synced 2026-11-21 18:40:47 +08:00
feat: log start time and duration in run log
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
@@ -29,6 +29,8 @@ pub struct RunLog {
|
||||
runspec: Option<RunSpec>,
|
||||
runspec_error: Option<String>,
|
||||
adapter_run_id: Option<RunId>,
|
||||
started: Option<SystemTime>,
|
||||
duration: Option<Duration>,
|
||||
}
|
||||
|
||||
impl RunLog {
|
||||
@@ -80,6 +82,14 @@ impl RunLog {
|
||||
self.runspec_error = Some(format!("{}", e));
|
||||
}
|
||||
|
||||
pub fn started(&mut self, ts: SystemTime) {
|
||||
self.started = Some(ts);
|
||||
}
|
||||
|
||||
pub fn duration(&mut self, dur: Duration) {
|
||||
self.duration = Some(dur);
|
||||
}
|
||||
|
||||
// FIXME: refactor this to maybe use a builder pattern?
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn runcmd(
|
||||
@@ -155,6 +165,25 @@ impl RunLog {
|
||||
} else {
|
||||
Element::new(Tag::Span)
|
||||
})
|
||||
.with_child({
|
||||
let ts = if let Some(ts) = &self.started {
|
||||
Element::new(Tag::Span).with_text(×tamp(ts))
|
||||
} else {
|
||||
Element::new(Tag::Span)
|
||||
};
|
||||
Element::new(Tag::Li).with_text("Started: ").with_child(ts)
|
||||
})
|
||||
.with_child({
|
||||
let dur = if let Some(dur) = &self.duration {
|
||||
Element::new(Tag::Span).with_text(&format!("{:1}", dur.as_secs_f64()))
|
||||
} else {
|
||||
Element::new(Tag::Span)
|
||||
};
|
||||
Element::new(Tag::Li)
|
||||
.with_text("Duration: ")
|
||||
.with_child(dur)
|
||||
.with_text(" s")
|
||||
})
|
||||
.with_child(
|
||||
Element::new(Tag::Li)
|
||||
.with_text("Result: ")
|
||||
|
||||
Reference in New Issue
Block a user