Skip to content

Commit

Permalink
chore(bb): hide debug() logs under --debug flag (#7008)
Browse files Browse the repository at this point in the history
This helps because currently `bootstrap.sh` compiles with assertions,
and therefore outputs all debug logs without this change.
  • Loading branch information
fcarreiro authored Jun 12, 2024
1 parent ca0e084 commit a8c3c3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,8 @@ int main(int argc, char* argv[])
{
try {
std::vector<std::string> 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;
Expand Down
5 changes: 4 additions & 1 deletion barretenberg/cpp/src/barretenberg/common/log.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
// Used for `vinfo` in log.hpp.
bool verbose_logging = false;
bool verbose_logging = false;

// Used for `debug` in log.hpp.
bool debug_logging = false;
5 changes: 4 additions & 1 deletion barretenberg/cpp/src/barretenberg/common/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ template <typename... Args> std::string benchmark_format(Args... args)
return os.str();
}

extern bool debug_logging;
#ifndef NDEBUG
template <typename... Args> inline void debug(Args... args)
{
logstr(format(args...).c_str());
if (debug_logging) {
logstr(format(args...).c_str());
}
}
#else
template <typename... Args> inline void debug(Args... /*unused*/) {}
Expand Down

0 comments on commit a8c3c3f

Please sign in to comment.