barretenberg
Loading...
Searching...
No Matches
log.hpp
1#pragma once
2#include <barretenberg/common/log.hpp>
3#include <iostream>
4
5extern bool verbose;
6
7template <typename... Args> inline void vinfo(Args... args)
8{
9 if (verbose) {
10 info(args...);
11 }
12}
13
28inline void writeRawBytesToStdout(const std::vector<uint8_t>& data)
29{
30 for (auto byte : data) {
31 // Safety: a byte and a char occupy one byte
32 std::cout.put(static_cast<char>(byte));
33 }
34}
35
41inline void writeUint64AsRawBytesToStdout(uint64_t value)
42{
43 // Convert the uint64_t to a vector of bytes, since std::cout.put
44 // only accepts a single byte.
45 std::vector<uint8_t> bytes;
46 bytes.reserve(sizeof(uint64_t));
47
48 for (size_t i = 0; i < sizeof(uint64_t); ++i) {
49 bytes.push_back(static_cast<uint8_t>(value & 0xFF));
50 value >>= 8;
51 }
52
53 writeRawBytesToStdout(bytes);
54}
55
61inline void writeStringToStdout(const std::string& str)
62{
63 for (char ch : str) {
64 std::cout.put(ch);
65 }
66}