On 14/12/2012 1:54 p.m., Alex Rousskov wrote:
Hello,
The attached patch adds Raw, an std::ostream manipulator to print
possibly non-terminated buffers and their labels/sizes.
The Raw manipulator tries to be smart about printing buffers at various
debugging levels: Large buffers are only printed at DBG_DATA by default.
This allows the caller to mix higher-level debug messages with dumping
of potentially large volumes of data. This smartness can be overruled
using an explicit minLevel() method call.
I think this manipulator can be useful in many places. The next patch I
will post illustrates such usage for helper debugging.
Thank you,
Alex.
How are these two different?
debugs(0,9, " label: " << StringArea(buf, 10));
debugs(0,9, "" << Raw("label", buf, 10));
Raw() would be elegant if it were inherited by buffer objects needing to
print their data as debugs(0,9, buf). But otherwise this is just making
a duplicate of the string+length object. We already have StringArea for
C++ and lstring for C code, MemBuf in a fashion for raw buffers, and
will have StringNG shortly as well.
Amos