From e64db1d3db4541227c9504a41835f6e640616d86 Mon Sep 17 00:00:00 2001 From: fcarreiro Date: Tue, 11 Jun 2024 11:42:06 +0000 Subject: [PATCH] Hide `debug()` logs under `--debug` flag. This helps because currently `bootstrap.sh` compiles with assertions, and therefore outputs all debug logs without this change. --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 3 ++- barretenberg/cpp/src/barretenberg/common/log.cpp | 5 ++++- barretenberg/cpp/src/barretenberg/common/log.hpp | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 8889bf29e9d..55a938fe44d 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -970,7 +970,8 @@ int main(int argc, char* argv[]) { try { std::vector args(argv + 1, argv + argc); - verbose_logging = flag_present(args, "-v") || flag_present(args, "--verbose_logging"); + debug_logging = flag_present(args, "-d") || flag_present(args, "--debug_logging"); + verbose_logging = debug_logging || flag_present(args, "-v") || flag_present(args, "--verbose_logging"); if (args.empty()) { std::cerr << "No command provided.\n"; return 1; diff --git a/barretenberg/cpp/src/barretenberg/common/log.cpp b/barretenberg/cpp/src/barretenberg/common/log.cpp index ed0d26e92db..68493a66abb 100644 --- a/barretenberg/cpp/src/barretenberg/common/log.cpp +++ b/barretenberg/cpp/src/barretenberg/common/log.cpp @@ -1,2 +1,5 @@ // Used for `vinfo` in log.hpp. -bool verbose_logging = false; \ No newline at end of file +bool verbose_logging = false; + +// Used for `debug` in log.hpp. +bool debug_logging = false; \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/log.hpp b/barretenberg/cpp/src/barretenberg/common/log.hpp index 19486b16307..dcf5d841dc0 100644 --- a/barretenberg/cpp/src/barretenberg/common/log.hpp +++ b/barretenberg/cpp/src/barretenberg/common/log.hpp @@ -47,10 +47,13 @@ template std::string benchmark_format(Args... args) return os.str(); } +extern bool debug_logging; #ifndef NDEBUG template inline void debug(Args... args) { - logstr(format(args...).c_str()); + if (debug_logging) { + logstr(format(args...).c_str()); + } } #else template inline void debug(Args... /*unused*/) {}