HomePhabricator

Add a more succinct logging syntax

Description

Add a more succinct logging syntax

This adds the LLDB_LOG macro, which enables one to write more succinct log
statements.
if (log)

log->Printf("log something: %d", var);

becomes
LLDB_LOG(log, "log something: {0}, var);

The macro still internally does the "if(log)" dance, so the arguments are only
evaluated if logging is enabled, meaning it has the same overhead as the
previous syntax.

Additionally, the log statements will be automatically prefixed with the file
and function generating the log (if the corresponding new argument to the "log
enable" command is enabled), so one does not need to manually specify this in
the log statement.

It also uses the new llvm formatv syntax, which means we don't have to worry
about PRIx64 macros and similar, and we can log complex object (llvm::StringRef,
lldb_private::Error, ...) more easily.

Differential Revision: https://reviews.llvm.org/D27459

Details

Committed
labathJan 18 2017, 3:00 AM
Differential Revision
D27459: Add a more succinct logging syntax
Parents
rL292359: [ELF] Move createThunks() after scanRelocations()
Branches
Unknown
Tags
Unknown