<div dir="ltr"><div dir="ltr" class="gmail_msg">Merging the thread over from lldb-commits:</div><div dir="ltr" class="gmail_msg"><br></div><div dir="ltr" class="gmail_msg"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 6, 2016 at 9:57 AM Jim Ingham via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">jingham added a comment.<br class="gmail_msg"><br class="gmail_msg">I not infrequently have some non-trivial code in the "if (log)" block that gathers the information that I am then going to print, or loops over entities printing them.  Putting more complex code like that inside a macro looks awful and is hard to debug.  I don't think that argues for not using the macros in the case where you are logging a simple string, but it does argue for keeping the old way available.<br class="gmail_msg"></blockquote><div>Not arguing against keeping the old way possible, but as an aside, llvm::formatv() can handle many of these cases pretty nicely.</div><div><br></div><div>For starters, it has builtin support for formatting ranges.  So if you're ever looping over entities formatting them, as long as the entity itself has a formatter defined, you can simply pass it directly to formatv and it will do the right thing.  (It has some customization support built in as well so you can control how to separate items).</div><div><br></div><div>Secondly, When you have to do some work to get the value you want to format, you could either define a custom formatter for the type in question, and the formatter does all the work, or you could write a function to return the value you want to format, and call that in the argument list, as long as the return type has an associated formatter.</div><div><br></div><div>I'm sure there will still be cases where you want to use the old method, but I think this would handle quite a few of them and reduce the amount of code you have to read / write when dealing with logging code.</div></div></div></div>