From d16f39ff580880933098cf6161a3aaf3dbf1a1a8 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Tue, 25 Apr 2023 17:10:11 +1000 Subject: [PATCH] chore: disable ansi codes when in GCP (#128) --- mpc-recovery/src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mpc-recovery/src/main.rs b/mpc-recovery/src/main.rs index 4346a078e..bb88a1e63 100644 --- a/mpc-recovery/src/main.rs +++ b/mpc-recovery/src/main.rs @@ -113,8 +113,14 @@ async fn load_account_creator_sk( #[tokio::main] async fn main() -> anyhow::Result<()> { - // install global collector configured based on RUST_LOG env var. - tracing_subscriber::fmt::init(); + // Install global collector configured based on RUST_LOG env var. + let mut subscriber = tracing_subscriber::fmt(); + // Check if running in Google Cloud Run: https://cloud.google.com/run/docs/container-contract#services-env-vars + if std::env::var("K_SERVICE").is_ok() { + // Disable colored logging as it messes up Google's log formatting + subscriber = subscriber.with_ansi(false); + } + subscriber.init(); let _span = tracing::trace_span!("cli").entered(); match Cli::parse() {