proxygen
proxygen::IOBufPrinter Class Referenceabstract

#include <Logging.h>

Inheritance diagram for proxygen::IOBufPrinter:
proxygen::BinPrinter proxygen::ChainInfoPrinter proxygen::Hex16Printer proxygen::HexFollyPrinter

Public Types

enum  Format : uint8_t { Format::HEX_FOLLY = 0, Format::HEX_16 = 1, Format::CHAIN_INFO = 2, Format::BIN = 3 }
 

Public Member Functions

 IOBufPrinter ()
 
virtual ~IOBufPrinter ()
 
virtual std::string print (const folly::IOBuf *buf)=0
 

Static Public Member Functions

static std::string printChain (const folly::IOBuf *buf, Format format, bool coalesce)
 
static std::string printHexFolly (const folly::IOBuf *buf, bool coalesce=false)
 
static std::string printHex16 (const folly::IOBuf *buf, bool coalesce=false)
 
static std::string printChainInfo (const folly::IOBuf *buf)
 
static std::string printBin (const folly::IOBuf *buf, bool coalesce=false)
 

Detailed Description

Definition at line 114 of file Logging.h.

Member Enumeration Documentation

Enumerator
HEX_FOLLY 
HEX_16 
CHAIN_INFO 
BIN 

Definition at line 116 of file Logging.h.

116  : uint8_t {
117  HEX_FOLLY = 0,
118  HEX_16 = 1,
119  CHAIN_INFO = 2,
120  BIN = 3,
121  };

Constructor & Destructor Documentation

proxygen::IOBufPrinter::IOBufPrinter ( )
inline

Definition at line 144 of file Logging.h.

144 {}
virtual proxygen::IOBufPrinter::~IOBufPrinter ( )
inlinevirtual

Definition at line 145 of file Logging.h.

References string.

145 {}

Member Function Documentation

virtual std::string proxygen::IOBufPrinter::print ( const folly::IOBuf buf)
pure virtual
static std::string proxygen::IOBufPrinter::printBin ( const folly::IOBuf buf,
bool  coalesce = false 
)
inlinestatic

Definition at line 140 of file Logging.h.

Referenced by proxygen::HPACKEncodeBuffer::toBin().

140  {
141  return printChain(buf, Format::BIN, coalesce);
142  }
static std::string printChain(const folly::IOBuf *buf, Format format, bool coalesce)
Definition: Logging.cpp:103
string proxygen::IOBufPrinter::printChain ( const folly::IOBuf buf,
Format  format,
bool  coalesce 
)
static

Definition at line 103 of file Logging.cpp.

References b, folly::IOBuf::clone(), folly::IOBuf::coalesce(), proxygen::ERROR, and uint8_t.

105  {
106  uint8_t index = (uint8_t) format;
107  if (printers.size() <= index) {
108  LOG(ERROR) << "invalid format: " << index;
109  return "";
110  }
111  auto printer = printers[index];
112  // empty chain
113  if (!buf) {
114  return "";
115  }
116 
117  unique_ptr<IOBuf> cbuf = nullptr;
118  if (coalesce) {
119  cbuf = buf->clone();
120  cbuf->coalesce();
121  buf = cbuf.get();
122  }
123  auto b = buf;
124  string res;
125  do {
126  res += printer->print(b);
127  b = b->next();
128  } while (b != buf);
129  return res;
130 }
char b
ByteRange coalesce()
Definition: IOBuf.h:1095
std::unique_ptr< IOBuf > clone() const
Definition: IOBuf.cpp:527
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)
Definition: Format.h:271
static std::string proxygen::IOBufPrinter::printChainInfo ( const folly::IOBuf buf)
inlinestatic

Definition at line 136 of file Logging.h.

Referenced by proxygen::dumpBinToFile().

136  {
137  return printChain(buf, Format::CHAIN_INFO, false);
138  }
static std::string printChain(const folly::IOBuf *buf, Format format, bool coalesce)
Definition: Logging.cpp:103
static std::string proxygen::IOBufPrinter::printHex16 ( const folly::IOBuf buf,
bool  coalesce = false 
)
inlinestatic

Definition at line 132 of file Logging.h.

132  {
133  return printChain(buf, Format::HEX_16, coalesce);
134  }
static std::string printChain(const folly::IOBuf *buf, Format format, bool coalesce)
Definition: Logging.cpp:103
static std::string proxygen::IOBufPrinter::printHexFolly ( const folly::IOBuf buf,
bool  coalesce = false 
)
inlinestatic

Definition at line 127 of file Logging.h.

Referenced by proxygen::HTTP2Codec::checkConnectionError(), proxygen::HTTP2Codec::parseHeadersDecodeFrames(), and proxygen::GzipHeaderCodec::parseNameValues().

128  {
129  return printChain(buf, Format::HEX_FOLLY, coalesce);
130  }
static std::string printChain(const folly::IOBuf *buf, Format format, bool coalesce)
Definition: Logging.cpp:103

The documentation for this class was generated from the following files: