diff --git a/src/dfx/src/commands/generate.rs b/src/dfx/src/commands/generate.rs index 840958162d..2844db9443 100644 --- a/src/dfx/src/commands/generate.rs +++ b/src/dfx/src/commands/generate.rs @@ -77,7 +77,7 @@ pub fn exec(env: &dyn Environment, opts: GenerateOpts) -> DfxResult { } for canister in canister_pool_load.canisters_to_build(&generate_config) { - canister.generate(&canister_pool_load, &generate_config)?; + canister.generate(log, &canister_pool_load, &generate_config)?; } Ok(()) diff --git a/src/dfx/src/lib/builders/mod.rs b/src/dfx/src/lib/builders/mod.rs index 0344c27b0e..78b1c0974f 100644 --- a/src/dfx/src/lib/builders/mod.rs +++ b/src/dfx/src/lib/builders/mod.rs @@ -12,6 +12,7 @@ use dfx_core::network::provider::get_network_context; use dfx_core::util; use fn_error_context::context; use handlebars::Handlebars; +use slog::{trace, Logger}; use std::borrow::Cow; use std::collections::BTreeMap; use std::ffi::OsStr; @@ -94,6 +95,7 @@ pub trait CanisterBuilder { /// Generate type declarations for the canister fn generate( &self, + logger: &Logger, pool: &CanisterPool, info: &CanisterInfo, config: &BuildConfig, @@ -137,8 +139,9 @@ pub trait CanisterBuilder { return Ok(()); } - eprintln!( - "Generating type declarations for canister {}:", + trace!( + logger, + "Generating type declarations for canister {}", &info.get_name() ); @@ -172,7 +175,7 @@ pub trait CanisterBuilder { output_did_ts_path.to_string_lossy() ) })?; - eprintln!(" {}", &output_did_ts_path.display()); + trace!(logger, " {}", &output_did_ts_path.display()); compile_handlebars_files("ts", info, generate_output_dir)?; } @@ -191,7 +194,7 @@ pub trait CanisterBuilder { output_did_js_path.to_string_lossy() ) })?; - eprintln!(" {}", &output_did_js_path.display()); + trace!(logger, " {}", &output_did_js_path.display()); compile_handlebars_files("js", info, generate_output_dir)?; } @@ -206,7 +209,7 @@ pub trait CanisterBuilder { std::fs::write(&output_mo_path, content).with_context(|| { format!("Failed to write to {}.", output_mo_path.to_string_lossy()) })?; - eprintln!(" {}", &output_mo_path.display()); + trace!(logger, " {}", &output_mo_path.display()); } // Candid @@ -216,7 +219,7 @@ pub trait CanisterBuilder { .with_extension("did"); dfx_core::fs::copy(&did_from_build, &output_did_path)?; dfx_core::fs::set_permissions_readwrite(&output_did_path)?; - eprintln!(" {}", &output_did_path.display()); + trace!(logger, " {}", &output_did_path.display()); } Ok(()) diff --git a/src/dfx/src/lib/models/canister.rs b/src/dfx/src/lib/models/canister.rs index c49e54c2d1..77667e95e3 100644 --- a/src/dfx/src/lib/models/canister.rs +++ b/src/dfx/src/lib/models/canister.rs @@ -104,8 +104,14 @@ impl Canister { } #[context("Failed while trying to generate type declarations for '{}'.", self.info.get_name())] - pub fn generate(&self, pool: &CanisterPool, build_config: &BuildConfig) -> DfxResult { - self.builder.generate(pool, &self.info, build_config) + pub fn generate( + &self, + logger: &Logger, + pool: &CanisterPool, + build_config: &BuildConfig, + ) -> DfxResult { + self.builder + .generate(logger, pool, &self.info, build_config) } #[context("Failed to post-process wasm of canister '{}'.", self.info.get_name())]