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

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 6 08:48:51 PST 2016


labath added a comment.

In https://reviews.llvm.org/D27459#614549, @zturner wrote:

> A couple comments:
>
> 1. If we're going to use `formatv` (yay!) then let's standardize.  No point mising `formatv` and streaming, especially when the former will almost always be less verbose.


In this change, I deliberately tried to mix styles, to show different ways of doing things. I also wanted to avoid prescribing the right API to use, as I've found llvm::formatv to be longer in the simple cases. However, hiding it in a macro is a good idea, and would remove that problem.

> 
> 
> 2. One of the concerns that came up last time was that of evaluating the arguments to the logging functions even in the case where it didn't get logged, because sometimes just calling the function to evaluate the parameter can be expensive.  To get around that you could pass the arguments directly to the macro instead of streaming them, and the macro could wrap everything in a lambda.

The macro expands to something like `if (!log) /*do nothing*/; else log << whatever`, so the streaming part only gets executed if logging is actually enabled. That said, I like the API you propose as well (and it could probably use something similar under the hood, to avoid messing around with lambdas).


https://reviews.llvm.org/D27459





More information about the lldb-commits mailing list