split instrumentation in 2 different places: harmony domain (for domain observability) & harmoy composer (for build/commands observability)
All checks were successful
Run Check Script / check (pull_request) Successful in -34s

This commit is contained in:
Ian Letourneau
2025-07-27 20:52:24 -04:00
parent 6f7e1640c1
commit 8fae9cf8c8
13 changed files with 209 additions and 120 deletions

View File

@@ -13,6 +13,10 @@ harmony_tui = { path = "../harmony_tui", optional = true }
inquire.workspace = true
tokio.workspace = true
env_logger.workspace = true
console = "0.16.0"
indicatif = "0.18.0"
lazy_static = "1.5.0"
log.workspace = true
[features]

View File

@@ -0,0 +1,28 @@
use harmony::instrumentation::{self, HarmonyEvent};
use indicatif::ProgressBar;
use std::sync::{Arc, Mutex};
pub async fn init() {
instrumentation::subscribe("CLI Logger", {
let current_spinner = Arc::new(Mutex::new(None::<ProgressBar>));
move |event| {
let spinner_clone = Arc::clone(&current_spinner);
async move {
let mut spinner_guard = spinner_clone.lock().unwrap();
match event {
HarmonyEvent::PrepareTopologyStarted { name } => {
println!(
"{} Preparing environment: {name}...",
crate::theme::EMOJI_TOPOLOGY
);
}
}
true
}
}
})
.await
}

View File

@@ -4,6 +4,9 @@ use harmony;
use harmony::{score::Score, topology::Topology};
use inquire::Confirm;
pub mod cli_logger; // FIXME: Don't make me pub
pub mod theme;
#[cfg(feature = "tui")]
use harmony_tui;

22
harmony_cli/src/theme.rs Normal file
View File

@@ -0,0 +1,22 @@
use console::Emoji;
use indicatif::ProgressStyle;
use lazy_static::lazy_static;
pub static EMOJI_HARMONY: Emoji<'_, '_> = Emoji("🎼", "");
pub static EMOJI_SUCCESS: Emoji<'_, '_> = Emoji("", "");
pub static EMOJI_ERROR: Emoji<'_, '_> = Emoji("⚠️", "");
pub static EMOJI_DEPLOY: Emoji<'_, '_> = Emoji("🚀", "");
pub static EMOJI_TOPOLOGY: Emoji<'_, '_> = Emoji("📦", "");
lazy_static! {
pub static ref SPINNER_STYLE: ProgressStyle = ProgressStyle::default_spinner()
.template(" {spinner:.green} {msg}")
.unwrap()
.tick_strings(&["", "", "", "", "", "", "", "", "", ""]);
pub static ref SUCCESS_SPINNER_STYLE: ProgressStyle = SPINNER_STYLE
.clone()
.tick_strings(&[format!("{}", EMOJI_SUCCESS).as_str()]);
pub static ref ERROR_SPINNER_STYLE: ProgressStyle = SPINNER_STYLE
.clone()
.tick_strings(&[format!("{}", EMOJI_ERROR).as_str()]);
}