diff --git a/assembly/Cargo.toml b/assembly/Cargo.toml index 34e54d669a..c541dd81fa 100644 --- a/assembly/Cargo.toml +++ b/assembly/Cargo.toml @@ -18,8 +18,9 @@ doctest = false [features] default = ["std"] -std = ["vm-core/std"] +std = ["vm-core/std", "log/std"] [dependencies] +log = { version = "0.4", default-features = false, optional = true } num_enum = "0.7" vm-core = { package = "miden-core", path = "../core", version = "0.8", default-features = false } diff --git a/assembly/src/assembler/mod.rs b/assembly/src/assembler/mod.rs index af92112779..dba05fd9d8 100644 --- a/assembly/src/assembler/mod.rs +++ b/assembly/src/assembler/mod.rs @@ -264,6 +264,12 @@ impl Assembler { } } + // log the completion of the module + log::debug!( + "\n - Module \"{}\" has been compiled", + path.unwrap_or(&LibraryPath::anon_path()) + ); + Ok(proc_roots) } diff --git a/miden/examples/merkle_store/merkle_store.masm b/miden/examples/merkle_store/merkle_store.masm index c7c01d8f52..3d8fca8f90 100644 --- a/miden/examples/merkle_store/merkle_store.masm +++ b/miden/examples/merkle_store/merkle_store.masm @@ -1,3 +1,5 @@ +use.std::math::u64 + begin # push the root of the Partial Merkle Tree on the stack push.0x82bb4d9a8e93582f1387611949703eecd8e4c74b904880f9c9c85f1fc1d7576d @@ -33,6 +35,11 @@ begin push.22.0.0.0 assert_eqw + + dropw + push.1.2 + exec.u64::checked_add + end diff --git a/miden/src/cli/data.rs b/miden/src/cli/data.rs index aef6b6b691..0ff8927781 100644 --- a/miden/src/cli/data.rs +++ b/miden/src/cli/data.rs @@ -10,7 +10,7 @@ use serde_derive::{Deserialize, Serialize}; use std::{ collections::HashMap, fs, - io::Write, + io::{stdout, Write}, path::{Path, PathBuf}, time::Instant, }; @@ -406,6 +406,7 @@ impl ProgramFile { L: Library, { print!("Compiling program... "); + stdout().flush().expect("Couldn't flush stdout"); let now = Instant::now(); // compile program diff --git a/miden/src/cli/prove.rs b/miden/src/cli/prove.rs index eb9b7d8d33..0c13cbf8d1 100644 --- a/miden/src/cli/prove.rs +++ b/miden/src/cli/prove.rs @@ -2,7 +2,7 @@ use super::data::{Debug, InputFile, Libraries, OutputFile, ProgramFile, ProofFil use clap::Parser; use miden::ProvingOptions; use processor::{DefaultHost, ExecutionOptions, ExecutionOptionsError}; -use std::{io::Write, path::PathBuf, time::Instant}; +use std::{path::PathBuf, time::Instant}; // TODO check if clap is supporting automatic generation of list values of hash function #[derive(Debug, Clone, Parser)] @@ -65,12 +65,6 @@ impl ProveCmd { println!("Prove program"); println!("============================================================"); - // configure logging - env_logger::Builder::new() - .format(|buf, record| writeln!(buf, "{}", record.args())) - .filter_level(log::LevelFilter::Debug) - .init(); - // load libraries from files let libraries = Libraries::new(&self.library_paths)?; diff --git a/miden/src/main.rs b/miden/src/main.rs index cd3e8bb64b..9e51f05725 100644 --- a/miden/src/main.rs +++ b/miden/src/main.rs @@ -1,6 +1,7 @@ use clap::Parser; use core::fmt; use miden::{AssemblyError, ExecutionError}; +use std::io::Write; mod cli; mod examples; @@ -53,6 +54,16 @@ pub fn main() { // read command-line args let cli = Cli::parse(); + // configure logging + // if logging level is not specified, set level to "warn" + if std::env::var("MIDEN_LOG").is_err() { + std::env::set_var("MIDEN_LOG", "warn"); + } + // use "MIDEN_LOG" environment variable to change the logging level + env_logger::Builder::from_env("MIDEN_LOG") + .format(|buf, record| writeln!(buf, "{}", record.args())) + .init(); + // execute cli action if let Err(error) = cli.execute() { println!("{}", error);