33 lines
987 B
Rust
33 lines
987 B
Rust
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}");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|