[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 08:32:44 PST 2016


zturner added a comment.

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.

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.

Combining #1 and #2 above, maybe you end up with something like this (not tested, probably needs some tweaking to work):

  #define LLDB_LOG(...) LLDB_LOG_([]() { return llvm::formatv(__VA_ARGS__); }
  
  LLDB_LOG("pid = {0}: tracking new thread tid {1}", GetID(), tid);


https://reviews.llvm.org/D27459





More information about the lldb-commits mailing list