[Lldb-commits] [PATCH] D117382: [NFC] Cleanup log channel stuff to all be consistent and use 64 bit log channel mask.

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 17 01:26:33 PST 2022


labath added a comment.

It is definitely an improvement, but I can't help but wonder, since we're going to be touching every GetLog line with this, if we couldn't go even further.

The various LLDB_LOG have helped a lot, but one of the things that still bothers me is the verbosity of the GetLog statements. `GetLogIfAllCategoriesSet(LIBLLDB_LOG_WHATEVER)` is long enough as it is, and this prepends `LLDBLog::` on top of that.

Here's a straw-man proposal to make that shorter (and safer). Instead of macros, we use (scoped) enums for denoting log categories. enums are not a preprocessor construct, so we can keep the identifiers relatively short. E.g. `LLDBLog::API` instead of `LLDB_LOG_API`. They also have types, which means we can use the compiler to check that the values are used appropriately. And thanks to that, we also don't need to have a long name for the log getter function. The logging could be as simple as

  Log *log = LogIfAny(LLDBLog::API); // Uses template magic to find the appropriate log class based on the type

If the name sounds too cryptic, we can also choose something longer like `GetLogIfAnySet` or variation thereof.

If you (all) think something like that would be useful, but don't have the time to do that, I can try to whip something up.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117382/new/

https://reviews.llvm.org/D117382



More information about the lldb-commits mailing list