Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
log.hpp File Reference
#include <algorithm>
#include <functional>
#include <sstream>
#include <string>
#include <vector>
#include "barretenberg/env/logstr.hpp"

Go to the source code of this file.

Classes

class  BenchmarkInfoCollator
 A class for saving benchmarks and printing them all at once in the end of the function. More...
 

Macros

#define BENCHMARK_INFO_PREFIX   "##BENCHMARK_INFO_PREFIX##"
 
#define BENCHMARK_INFO_SEPARATOR   "#"
 
#define BENCHMARK_INFO_SUFFIX   "##BENCHMARK_INFO_SUFFIX##"
 
#define BENCH_GATE_COUNT_START(builder, op_name)    uint64_t __bench_before = builder.get_num_finalized_gates_inefficient();
 
#define BENCH_GATE_COUNT_END(builder, op_name)
 
#define log_(level, ...)
 
#define log_fatal(...)   log_(LogLevel::FATAL, __VA_ARGS__)
 
#define log_error(...)   log_(LogLevel::ERROR, __VA_ARGS__)
 
#define log_warn(...)   log_(LogLevel::WARN, __VA_ARGS__)
 
#define important(...)   log_(LogLevel::WARN, "important: ", __VA_ARGS__)
 
#define info(...)   log_(LogLevel::INFO, __VA_ARGS__)
 
#define vinfo(...)   log_(LogLevel::VERBOSE, __VA_ARGS__)
 
#define log_verbose(...)   log_(LogLevel::VERBOSE, __VA_ARGS__)
 
#define debug(...)   log_(LogLevel::DEBUG, __VA_ARGS__)
 
#define log_trace(...)   log_(LogLevel::TRACE, __VA_ARGS__)
 

Typedefs

using LogFunction = std::function< void(LogLevel level, const std::string &msg)>
 

Enumerations

enum class  LogLevel : int {
  SILENT = 0 , FATAL = 1 , ERROR = 2 , WARN = 3 ,
  INFO = 4 , VERBOSE = 5 , DEBUG = 6 , TRACE = 7
}
 

Functions

template<typename... Args>
std::string format (Args... args)
 
template<typename T >
void benchmark_format_chain (std::ostream &os, T const &first)
 
template<typename T , typename... Args>
void benchmark_format_chain (std::ostream &os, T const &first, Args const &... args)
 
template<typename... Args>
std::string benchmark_format (Args... args)
 
void set_log_function (LogFunction new_log_function)
 
template<typename... Args>
void benchmark_info (Args...)
 Info used to store circuit statistics during CI/CD with concrete structure. Writes straight to log.
 

Variables

LogLevel bb_log_level
 
LogFunction log_function
 

Macro Definition Documentation

◆ BENCH_GATE_COUNT_END

#define BENCH_GATE_COUNT_END (   builder,
  op_name 
)
Value:
uint64_t __bench_after = builder.get_num_finalized_gates_inefficient(); \
std::cerr << "num gates with " << op_name << " = " << __bench_after - __bench_before << std::endl; \
benchmark_info(Builder::NAME_STRING, "Bigfield", op_name, "Gate Count", __bench_after - __bench_before);
AluTraceBuilder builder
Definition alu.test.cpp:124
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13

Definition at line 18 of file log.hpp.

◆ BENCH_GATE_COUNT_START

#define BENCH_GATE_COUNT_START (   builder,
  op_name 
)     uint64_t __bench_before = builder.get_num_finalized_gates_inefficient();

Definition at line 15 of file log.hpp.

◆ BENCHMARK_INFO_PREFIX

#define BENCHMARK_INFO_PREFIX   "##BENCHMARK_INFO_PREFIX##"

Definition at line 11 of file log.hpp.

◆ BENCHMARK_INFO_SEPARATOR

#define BENCHMARK_INFO_SEPARATOR   "#"

Definition at line 12 of file log.hpp.

◆ BENCHMARK_INFO_SUFFIX

#define BENCHMARK_INFO_SUFFIX   "##BENCHMARK_INFO_SUFFIX##"

Definition at line 13 of file log.hpp.

◆ debug

#define debug (   ...)    log_(LogLevel::DEBUG, __VA_ARGS__)

Definition at line 99 of file log.hpp.

◆ important

#define important (   ...)    log_(LogLevel::WARN, "important: ", __VA_ARGS__)

Definition at line 92 of file log.hpp.

◆ info

#define info (   ...)    log_(LogLevel::INFO, __VA_ARGS__)

Definition at line 93 of file log.hpp.

◆ log_

#define log_ (   level,
  ... 
)
Value:
do { \
if (level <= bb_log_level) { \
log_function(level, format(__VA_ARGS__)); \
} \
} while (0)
std::string format(Args... args)
Definition log.hpp:23
LogLevel bb_log_level
Definition log.cpp:9

Definition at line 82 of file log.hpp.

◆ log_error

#define log_error (   ...)    log_(LogLevel::ERROR, __VA_ARGS__)

Definition at line 90 of file log.hpp.

◆ log_fatal

#define log_fatal (   ...)    log_(LogLevel::FATAL, __VA_ARGS__)

Definition at line 89 of file log.hpp.

◆ log_trace

#define log_trace (   ...)    log_(LogLevel::TRACE, __VA_ARGS__)

Definition at line 100 of file log.hpp.

◆ log_verbose

#define log_verbose (   ...)    log_(LogLevel::VERBOSE, __VA_ARGS__)

Definition at line 95 of file log.hpp.

◆ log_warn

#define log_warn (   ...)    log_(LogLevel::WARN, __VA_ARGS__)

Definition at line 91 of file log.hpp.

◆ vinfo

#define vinfo (   ...)    log_(LogLevel::VERBOSE, __VA_ARGS__)

Definition at line 94 of file log.hpp.

Typedef Documentation

◆ LogFunction

using LogFunction = std::function<void(LogLevel level, const std::string& msg)>

Definition at line 76 of file log.hpp.

Enumeration Type Documentation

◆ LogLevel

enum class LogLevel : int
strong
Enumerator
SILENT 
FATAL 
ERROR 
WARN 
INFO 
VERBOSE 
DEBUG 
TRACE 

Definition at line 63 of file log.hpp.

Function Documentation

◆ benchmark_format()

template<typename... Args>
std::string benchmark_format ( Args...  args)

Definition at line 52 of file log.hpp.

◆ benchmark_format_chain() [1/2]

template<typename T >
void benchmark_format_chain ( std::ostream &  os,
T const &  first 
)

Definition at line 30 of file log.hpp.

◆ benchmark_format_chain() [2/2]

template<typename T , typename... Args>
void benchmark_format_chain ( std::ostream &  os,
T const &  first,
Args const &...  args 
)

Definition at line 41 of file log.hpp.

◆ benchmark_info()

template<typename... Args>
void benchmark_info ( Args...  )
inline

Info used to store circuit statistics during CI/CD with concrete structure. Writes straight to log.

Automatically appends the necessary prefix and suffix, as well as separators.

Template Parameters
Args
Parameters
args

Definition at line 121 of file log.hpp.

◆ format()

template<typename... Args>
std::string format ( Args...  args)

Definition at line 23 of file log.hpp.

◆ set_log_function()

void set_log_function ( LogFunction  new_log_function)

Definition at line 21 of file log.cpp.

Variable Documentation

◆ bb_log_level

LogLevel bb_log_level
extern

Definition at line 9 of file log.cpp.

◆ log_function

LogFunction log_function
extern

Definition at line 19 of file log.cpp.