[Lldb-commits] [PATCH] D107079: [lldb] Change the log format to JSON instead of plain text

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 29 07:51:06 PDT 2021


teemperor created this revision.
teemperor added a reviewer: LLDB.
teemperor added a project: LLDB.
Herald added a subscriber: JDevlieghere.
teemperor requested review of this revision.

LLDB has a quite extensive logging framework that is mostly used to help with bug reporting where users
are usually requested to attach the generated logs after reproducing a bug locally.

Right now all logging is done in plain text where usually one line in the text file equals one log message (but
that is more of a guidelines, there are multiline log messages too).

While the plain text logs are easy to read without any tools, they are often also really limiting the usefulness
of LLDB's logging framework:

- The plain text logs become hard to read when they are filled out with too much information. Because of that

we often only request users to enable a small subset of the logging functionality in LLDB. When later on the
bug is outside one of the initially activated logging channels, we have to go back to the user and ask them to
recreate the logs with more channels. We also essentially never tell users to enable other useful parts of the
logging system (such as the automatic stacktraces) for that reason.

- We can't easily write tools that make viewing logs easier. Writing a parser that extracts the different parts of a

log message from the plain text format is rather difficult.

This patch changes the output format of the log files to JSON. Every log message is now a serialized JSON object
(that is now also guaranteed to occupy exactly one line) that is just appended to the log file. For convenience I
also added a trailing comma behind every JSON object so that a log file can always be turned into a single JSON
object again that by just surrounding it with `[]` and removing the last comma (for strict parsers).


https://reviews.llvm.org/D107079

Files:
  lldb/include/lldb/Utility/Log.h
  lldb/packages/Python/lldbsuite/test/lldbutil.py
  lldb/source/Utility/Log.cpp
  lldb/test/API/api/log/TestAPILog.py
  lldb/test/API/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py
  lldb/unittests/Utility/LogTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107079.362773.patch
Type: text/x-patch
Size: 16093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210729/2c680ba1/attachment-0001.bin>


More information about the lldb-commits mailing list