wip: Report harmony execution outcome
This commit is contained in:
32
harmony_cli/src/cli_reporter.rs
Normal file
32
harmony_cli/src/cli_reporter.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use std::sync::Mutex;
|
||||
|
||||
use harmony::instrumentation::{self, HarmonyEvent};
|
||||
use log::info;
|
||||
|
||||
pub fn init() {
|
||||
let details: Mutex<Vec<String>> = Mutex::new(vec![]);
|
||||
|
||||
instrumentation::subscribe("Harmony CLI Reporter", {
|
||||
move |event| {
|
||||
let mut details = details.lock().unwrap();
|
||||
|
||||
if let HarmonyEvent::InterpretExecutionFinished {
|
||||
execution_id: _,
|
||||
topology: _,
|
||||
interpret: _,
|
||||
score: _,
|
||||
outcome: Ok(outcome),
|
||||
} = event
|
||||
{
|
||||
if outcome.status == harmony::interpret::InterpretStatus::SUCCESS {
|
||||
details.extend(outcome.details.clone());
|
||||
}
|
||||
} else if let HarmonyEvent::HarmonyFinished = event {
|
||||
info!("Here's a summary of what happened:");
|
||||
for detail in details.iter() {
|
||||
println!("{detail}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user