-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlog.cpp
More file actions
33 lines (29 loc) · 945 Bytes
/
log.cpp
File metadata and controls
33 lines (29 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "log.h"
namespace quic {
std::ostream& operator<<(std::ostream& o, const buffer_printer& bp) {
auto& b = bp.buf;
auto oldfill = o.fill();
o.fill('0');
o << "Buffer[" << b.size() << "/0x" << std::hex << b.size() << " bytes]:";
for (size_t i = 0; i < b.size(); i += 32) {
o << "\n" << std::setw(4) << i << " ";
size_t stop = std::min(b.size(), i+32);
for (size_t j = 0; j < 32; j++) {
auto k = i + j;
if (j % 4 == 0) o << ' ';
if (k >= stop) o << " ";
else o << std::setw(2) << std::to_integer<uint_fast16_t>(b[k]);
}
o << u8" ┃";
for (size_t j = i; j < stop; j++) {
auto c = std::to_integer<char>(b[j]);
if (c == 0x00) o << u8"∅";
else if (c < 0x20 || c > 0x7e) o << u8"·";
else o << c;
}
o << u8"┃";
}
o << std::dec;
return o;
}
}