Skip to content

Commit

Permalink
chore: conservatively use log::info instead of println for some expre…
Browse files Browse the repository at this point in the history
…ssions (#3766)

# Description

If you want to see info level logs, you can do `NOIR_LOG=info nargo
compile` by default if that environment variable is not set, then it
will only print out error level logs

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*



## Additional Context



## Documentation\*

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.

---------

Co-authored-by: Tom French <[email protected]>
  • Loading branch information
kevaundray and TomAFrench authored Dec 11, 2023
1 parent fa93aa7 commit 0a23d42
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 8 deletions.
45 changes: 43 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const_format = "0.2.30"
num-bigint = "0.4"
num-traits = "0.2"
similar-asserts = "1.5.0"
log = "0.4.17"

[profile.dev]
# This is required to be able to run `cargo test` in acvm_js due to the `locals exceeds maximum` error.
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ wasm-bindgen-futures.workspace = true
console_error_panic_hook.workspace = true
gloo-utils.workspace = true
js-sys.workspace = true
log.workspace = true

serde = { version = "1.0.136", features = ["derive"] }
log = "0.4.17"
wasm-logger = "0.2.0"
const-str = "0.5.5"

Expand Down
1 change: 0 additions & 1 deletion compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,6 @@ mod test {
// }
let ssa = ssa.flatten_cfg();
let main = ssa.main();
println!("{ssa}");
assert_eq!(main.reachable_blocks().len(), 1);

let store_count = count_instruction(main, |ins| matches!(ins, Instruction::Store { .. }));
Expand Down
2 changes: 1 addition & 1 deletion compiler/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ js-sys.workspace = true
cfg-if.workspace = true
console_error_panic_hook.workspace = true
gloo-utils.workspace = true
log.workspace = true

log = "0.4.17"
wasm-logger = "0.2.0"

# This is an unused dependency, we are adding it
Expand Down
1 change: 1 addition & 0 deletions tooling/backend_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ thiserror.workspace = true
serde.workspace = true
serde_json.workspace = true
bb_abstraction_leaks.workspace = true
log.workspace = true

tempfile = "3.6.0"

Expand Down
4 changes: 2 additions & 2 deletions tooling/backend_interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ impl Backend {

// If version doesn't match then download the correct version.
Ok(version_string) => {
println!("`{ACVM_BACKEND_BARRETENBERG}` version `{version_string}` is different from expected `{BB_VERSION}`. Downloading expected version...");
log::warn!("`{ACVM_BACKEND_BARRETENBERG}` version `{version_string}` is different from expected `{BB_VERSION}`. Downloading expected version...");
let bb_url = std::env::var("BB_BINARY_URL")
.unwrap_or_else(|_| bb_abstraction_leaks::BB_DOWNLOAD_URL.to_owned());
download_backend(&bb_url, binary_path)?;
}

// If `bb` fails to report its version, then attempt to fix it by re-downloading the binary.
Err(_) => {
println!("Could not determine version of `{ACVM_BACKEND_BARRETENBERG}`. Downloading expected version...");
log::warn!("Could not determine version of `{ACVM_BACKEND_BARRETENBERG}`. Downloading expected version...");
let bb_url = std::env::var("BB_BINARY_URL")
.unwrap_or_else(|_| bb_abstraction_leaks::BB_DOWNLOAD_URL.to_owned());
download_backend(&bb_url, binary_path)?;
Expand Down
2 changes: 1 addition & 1 deletion tooling/backend_interface/src/proof_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Backend {
if let Ok(backend_info) = self.get_backend_info() {
(backend_info.0, backend_info.1)
} else {
println!("No valid backend found, defaulting to Plonk with width 3 and all opcodes supported");
log::warn!("No valid backend found, defaulting to Plonk with width 3 and all opcodes supported");
(Language::PLONKCSat { width: 3 }, BackendOpcodeSupport::all())
}
}
Expand Down
1 change: 1 addition & 0 deletions tooling/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ hex.workspace = true
similar-asserts.workspace = true
termcolor = "1.1.2"
color-eyre = "0.6.2"
env_logger = "0.9.0"
tokio = { version = "1.0", features = ["io-std"] }

# Backends
Expand Down
4 changes: 4 additions & 0 deletions tooling/nargo_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ mod cli;
mod errors;

use color_eyre::config::HookBuilder;
use env_logger::{Builder, Env};

const PANIC_MESSAGE: &str = "This is a bug. We may have already fixed this in newer versions of Nargo so try searching for similar issues at https://github.com/noir-lang/noir/issues/.\nIf there isn't an open issue for this bug, consider opening one at https://github.com/noir-lang/noir/issues/new?labels=bug&template=bug_report.yml";

fn main() {
let env = Env::default().filter_or("NOIR_LOG", "error"); // Default to 'error' if NOIR_LOG is not set
Builder::from_env(env).init();

// Register a panic hook to display more readable panic messages to end-users
let (panic_hook, _) =
HookBuilder::default().display_env_section(false).panic_section(PANIC_MESSAGE).into_hooks();
Expand Down

0 comments on commit 0a23d42

Please sign in to comment.