[Lldb-commits] [PATCH] D27459: Straw-man proposal for new logging syntax

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 6 09:52:13 PST 2016


zturner added a comment.

In https://reviews.llvm.org/D27459#614672, @clayborg wrote:

> Does llvm::formatv allow you to specify the base of integers, or just where they go? Can you give it width, number base, leading characters and other things like a lot of what printf does?


You can specify hex and decimal.  No other bases, although that could be added.  To the other questions, yes.  Here are some examples:

  std::string S = formatv("{0}", 7);   // S = "7"
  S = formatv("{0,-3}", 7);   // S = "7  "  (-3 indicates left align inside a field of width 3)
  S = formatv("{0,=3}", 7);  // S = " 7 "  (=3 indicates center align inside a field of width 3)
  S = formatv("{0,=10; x}, 23);  // S = "   0x17   "  (=10 indicates center align inside a field of width 10, x indicates hex.   , is the alignment marker ; is the style marker
  S = formatv("{0;P}", 0.12345);  // S = "12.35%"  (P indicates to format as a percentage, only valid for floating point types.  Default precision is 2
  S = formatv("{0;3P}", 0.12345);  // S = "12.345%"  (P indicates to format as a percentage, only valid for floating point types.  Explicitly specify precision of 3.

There are lots of other things you can do, and since I wrote / designed it, I'm happy to add additional features that you or others request.


https://reviews.llvm.org/D27459





More information about the lldb-commits mailing list