Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for writing tracing debug info to file #3790

Merged
merged 4 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 63 additions & 9 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
5 changes: 5 additions & 0 deletions tooling/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ tokio = { version = "1.0", features = ["io-std"] }
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
13 changes: 13 additions & 0 deletions tooling/nargo_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,28 @@ 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, _) =
HookBuilder::default().display_env_section(false).panic_section(PANIC_MESSAGE).into_hooks();
Expand Down
Loading