mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-07 16:01:24 +00:00
add colors to procedure logs
This commit is contained in:
Generated
+1
@@ -1431,6 +1431,7 @@ version = "1.7.3"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"command",
|
||||
"formatting",
|
||||
"monitor_client",
|
||||
"run_command",
|
||||
"tracing",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::pin::Pin;
|
||||
|
||||
use formatting::{bold, colored, muted, Color};
|
||||
use monitor_client::{
|
||||
api::execute::RunProcedure,
|
||||
entities::{
|
||||
@@ -51,7 +52,11 @@ fn resolve_inner(
|
||||
// and will panic otherwise.
|
||||
update.push_simple_log(
|
||||
"execute_procedure",
|
||||
format!("executing procedure {}", procedure.name),
|
||||
format!(
|
||||
"{}: executing procedure '{}'",
|
||||
muted("INFO"),
|
||||
bold(&procedure.name)
|
||||
),
|
||||
);
|
||||
|
||||
// get the action state for the procedure (or insert default).
|
||||
@@ -75,12 +80,20 @@ fn resolve_inner(
|
||||
Ok(_) => {
|
||||
update.push_simple_log(
|
||||
"execution ok",
|
||||
"the procedure has completed with no errors",
|
||||
format!(
|
||||
"{}: the procedure has {} with no errors",
|
||||
muted("INFO"),
|
||||
colored("completed", Color::Green)
|
||||
),
|
||||
);
|
||||
}
|
||||
Err(e) => update.push_error_log(
|
||||
"execution error",
|
||||
serialize_error_pretty(&e),
|
||||
format!(
|
||||
"{}: {}",
|
||||
colored("ERROR", Color::Red),
|
||||
serialize_error_pretty(&e)
|
||||
),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use anyhow::{anyhow, Context, Ok};
|
||||
use formatting::{bold, colored, muted, Color};
|
||||
use futures::future::join_all;
|
||||
use monitor_client::{
|
||||
api::execute::Execution,
|
||||
@@ -26,7 +27,11 @@ pub async fn execute_procedure(
|
||||
}
|
||||
add_line_to_update(
|
||||
update,
|
||||
&format!("executing stage: {}", stage.name),
|
||||
&format!(
|
||||
"{}: executing stage: '{}'",
|
||||
muted("INFO"),
|
||||
bold(&stage.name)
|
||||
),
|
||||
)
|
||||
.await;
|
||||
let timer = Instant::now();
|
||||
@@ -44,16 +49,19 @@ pub async fn execute_procedure(
|
||||
.await
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"failed stage '{}' execution after {:?}",
|
||||
stage.name,
|
||||
"{}: failed stage '{}' execution after {:?}",
|
||||
colored("ERROR", Color::Red),
|
||||
bold(&stage.name),
|
||||
timer.elapsed(),
|
||||
)
|
||||
})?;
|
||||
add_line_to_update(
|
||||
update,
|
||||
&format!(
|
||||
"finished stage '{}' execution in {:?} ✅",
|
||||
stage.name,
|
||||
"{}: {} stage '{}' execution in {:?}",
|
||||
muted("INFO"),
|
||||
colored("finished", Color::Green),
|
||||
bold(&stage.name),
|
||||
timer.elapsed()
|
||||
),
|
||||
)
|
||||
@@ -72,9 +80,15 @@ async fn execute_stage(
|
||||
) -> anyhow::Result<()> {
|
||||
let futures = executions.into_iter().map(|execution| async move {
|
||||
let now = Instant::now();
|
||||
add_line_to_update(update, &format!("executing: {execution:?}"))
|
||||
.await;
|
||||
let fail_log = format!("failed on {execution:?}");
|
||||
add_line_to_update(
|
||||
update,
|
||||
&format!("{}: executing: {execution:?}", muted("INFO")),
|
||||
)
|
||||
.await;
|
||||
let fail_log = format!(
|
||||
"{}: failed on {execution:?}",
|
||||
colored("ERROR", Color::Red)
|
||||
);
|
||||
let res =
|
||||
execute_execution(execution.clone(), parent_id, parent_name)
|
||||
.await
|
||||
@@ -82,7 +96,9 @@ async fn execute_stage(
|
||||
add_line_to_update(
|
||||
update,
|
||||
&format!(
|
||||
"finished execution in {:?}: {execution:?}",
|
||||
"{}: {} execution in {:?}: {execution:?}",
|
||||
muted("INFO"),
|
||||
colored("finished", Color::Green),
|
||||
now.elapsed()
|
||||
),
|
||||
)
|
||||
@@ -266,8 +282,9 @@ async fn execute_execution(
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow!(
|
||||
"execution not successful. see update {}",
|
||||
update.id
|
||||
"{}: execution not successful. see update '{}'",
|
||||
colored("ERROR", Color::Red),
|
||||
bold(&update.id),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ homepage.workspace = true
|
||||
|
||||
[dependencies]
|
||||
monitor_client.workspace = true
|
||||
formatting.workspace = true
|
||||
command.workspace = true
|
||||
#
|
||||
run_command.workspace = true
|
||||
|
||||
+8
-1
@@ -5,6 +5,7 @@ use std::{
|
||||
|
||||
use anyhow::Context;
|
||||
use command::run_monitor_command;
|
||||
use formatting::{bold, muted};
|
||||
use monitor_client::entities::{
|
||||
all_logs_success, monitor_timestamp, to_monitor_name, update::Log,
|
||||
CloneArgs, LatestCommit, SystemCommand,
|
||||
@@ -252,7 +253,13 @@ pub async fn get_commit_hash_log(
|
||||
let log = Log {
|
||||
stage: "latest commit".into(),
|
||||
command,
|
||||
stdout: format!("hash: {short}\nmessage: {msg}"),
|
||||
stdout: format!(
|
||||
"{} {}\n{} {}",
|
||||
muted("hash:"),
|
||||
bold(short),
|
||||
muted("message:"),
|
||||
bold(msg),
|
||||
),
|
||||
stderr: String::new(),
|
||||
success: true,
|
||||
start_ts,
|
||||
|
||||
Reference in New Issue
Block a user