Skip to content

Commit

Permalink
feat: allow to turn tracing on
Browse files Browse the repository at this point in the history
  • Loading branch information
kobyhallx committed Dec 13, 2023
1 parent 24ff886 commit 1cbe30b
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 55 deletions.
116 changes: 65 additions & 51 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ num-traits = "0.2"
similar-asserts = "1.5.0"
log = "0.4.17"

tracing = "0.1.40"

[profile.dev]
# This is required to be able to run `cargo test` in acvm_js due to the `locals exceeds maximum` error.
# See https://ritik-mishra.medium.com/resolving-the-wasm-pack-error-locals-exceed-maximum-ec3a9d96685b
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"acir",
"acvm",
"aeiou",
"appender",
"arithmetization",
"arity",
"arkworks",
Expand Down
6 changes: 5 additions & 1 deletion tooling/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ 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
backend-interface = { path = "../backend_interface" }
bb_abstraction_leaks.workspace = true

# Logs
tracing.workspace = true
tracing-subscriber = "0.3.18"
tracing-appender = "0.2.3"

[target.'cfg(not(unix))'.dependencies]
tokio-util = { version = "0.7.8", features = ["compat"] }

Expand Down
15 changes: 12 additions & 3 deletions tooling/nargo_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,23 @@ mod backends;
mod cli;
mod errors;

use std::env;

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

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();
// Setup tracing
if let Ok(log_dir) = env::var("NARGO_LOG_DIR") {
let debug_file = rolling::daily(log_dir, "nargo-log");
tracing_subscriber::fmt()
.with_writer(debug_file)
.with_ansi(false)
.with_max_level(tracing::Level::TRACE)
.init();
}

// Register a panic hook to display more readable panic messages to end-users
let (panic_hook, _) =
Expand Down

0 comments on commit 1cbe30b

Please sign in to comment.