27 using std::stringstream;
28 using std::unique_ptr;
37 vector<proxygen::IOBufPrinter*> printers = {
63 for (
size_t i = 0;
i < buf->
length();
i++) {
64 snprintf(tmp, 3,
"%02x", data[
i]);
66 if ((i + 1) % 2 == 0) {
69 if ((i + 1) % 16 == 0) {
78 out <<
"iobuf of size " << buf->
length()
84 static uint8_t bytesPerLine = 8;
87 for (
size_t i = 0;
i < buf->
length();
i++) {
88 for (
int b = 7;
b >= 0;
b--) {
89 out += data[
i] & 1 <<
b ?
'1' :
'0';
92 out += isprint(data[
i]) ? data[
i] :
' ';
93 if ((i + 1) % bytesPerLine == 0) {
107 if (printers.size() <= index) {
108 LOG(
ERROR) <<
"invalid format: " << index;
111 auto printer = printers[index];
117 unique_ptr<IOBuf> cbuf =
nullptr;
126 res += printer->print(
b);
134 bool exists = (stat(filename.c_str(), &fstat) == 0);
139 std::ofstream file(filename, std::ofstream::binary);
140 if (!file.is_open()) {
141 LOG(
ERROR) <<
"cannot open file " << filename;
150 file.write((
const char *)buf->
data(), buf->
length());
152 }
while (buf != first);
155 <<
" to " << filename;
158 namespace logging_details {
void dumpBinToFile(const string &filename, const IOBuf *buf)
string hexStr(StringPiece sp)
std::string sformat(StringPiece fmt, Args &&...args)
std::string getStackTrace()
const uint8_t * data() const
std::unique_ptr< IOBuf > clone() const
std::size_t tailroom() const
static std::string printChain(const folly::IOBuf *buf, Format format, bool coalesce)
static std::atomic< StackTraceGetterPtr > & stackTraceGetter()
std::string print(const folly::IOBuf *buf) override
std::size_t length() const
void hexDump(const void *ptr, size_t size, OutIt out)
static std::string printChainInfo(const folly::IOBuf *buf)
std::string print(const folly::IOBuf *buf) override
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)
Range< const char * > StringPiece
std::string print(const folly::IOBuf *buf) override
static constexpr uint64_t data[1]
constexpr detail::First first
std::string print(const folly::IOBuf *buf) override