forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 344
Cherrypick logging changes #5132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JDevlieghere
merged 11 commits into
stable/20220421
from
🍒/rebranch/6ff49af33d09+6ac608b3d897+de7475657156+09dea546692f+70841b97eb2e+6879391908ca+1e5d5261e2b6+87a32939611a+be265d25ca5e+9bdb7e573427
Aug 16, 2022
The head ref may contain hidden characters: "\u{1F352}/rebranch/6ff49af33d09+6ac608b3d897+de7475657156+09dea546692f+70841b97eb2e+6879391908ca+1e5d5261e2b6+87a32939611a+be265d25ca5e+9bdb7e573427"
Merged
Cherrypick logging changes #5132
JDevlieghere
merged 11 commits into
stable/20220421
from
🍒/rebranch/6ff49af33d09+6ac608b3d897+de7475657156+09dea546692f+70841b97eb2e+6879391908ca+1e5d5261e2b6+87a32939611a+be265d25ca5e+9bdb7e573427
Aug 16, 2022
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JDevlieghere
commented
Aug 16, 2022
- [lldb] Introduce the concept of a log handler (NFC)
- [lldb] Add RotatingLogHandler
- [lldb] Remove LogHandler::Create functions (NFC)
- [lldb] Support a buffered logging mode
- [lldb] Make thread safety the responsibility of the log handlers
- [lldb] Replace Host::SystemLog with Debugger::Report{Error,Warning}
- [lldb] Add SystemLogHandler for emitting log messages to the system log
- [lldb] Move Host::SystemLog out of !defined(_WIN32)
- [lldb] Add support for specifying a log handler
- [lldb] Add a log dump command
This patch introduces the concept of a log handlers. Log handlers allow customizing the way log output is emitted. The StreamCallback class tried to do something conceptually similar. The benefit of the log handler interface is that you don't need to conform to llvm's raw_ostream interface. Differential revision: https://reviews.llvm.org/D127922 (cherry picked from commit 6ff49af)
Add a log handler that maintains a circular buffer with a fixed size. Differential revision: https://reviews.llvm.org/D127937 (cherry picked from commit 6ac608b)
Remove the LogHandler::Create functions. Except for the StreamHandler they were just forwarding their arguments to std::make_shared. (cherry picked from commit de74756)
This patch adds a buffered logging mode to lldb. A buffer size can be passed to `log enable` with the -b flag. If no buffer size is specified, logging is unbuffered. Differential revision: https://reviews.llvm.org/D127986 (cherry picked from commit 09dea54)
Drop the thread-safe flag and make the locking strategy the responsibility of the individual log handler. Previously we got away with a non-thread safe mode because we were using unbuffered streams that rely on the underlying syscalls/OS for synchronization. With the introduction of log handlers, we can have arbitrary logic involved in writing out the logs. With this patch the log handlers can pick the most appropriate locking strategy for their particular implementation. Differential revision: https://reviews.llvm.org/D127922 (cherry picked from commit 70841b9)
As it exists today, Host::SystemLog is used exclusively for error reporting. With the introduction of diagnostic events, we have a better way of reporting those. Instead of printing directly to stderr, these messages now get printed to the debugger's error stream (when using the default event handler). Alternatively, if someone is listening for these events, they can decide how to display them, for example in the context of an IDE such as Xcode. This change also means we no longer write these messages to the system log on Darwin. As far as I know, nobody is relying on this, but I think this is something we could add to the diagnostic event mechanism. Differential revision: https://reviews.llvm.org/D128480 (cherry picked from commit 6879391)
Add a system log handler that emits log messages to the operating system log. In addition to the log handler itself, this patch also introduces a new Host::SystemLog helper function to abstract over writing to the system log. Differential revision: https://reviews.llvm.org/D128321 (cherry picked from commit 1e5d526)
The definition of Host::SystemLog was (unintentionally) guarded by !defined(_WIN32). (cherry picked from commit 87a3293)
This patch adds a new flag to `log enable`, allowing the user to specify a custom log handler. In addition to the default (stream) handler, this allows using the circular log handler (which logs to a fixed size, in-memory circular buffer) as well as the system log handler (which logs to the operating system log). Differential revision: https://reviews.llvm.org/D128323 (cherry picked from commit be265d2)
Add a log dump command to dump logs to a file. This only works for channels that have a log handler associated that supports dumping. For now that's limited to the circular log handler, but more could be added in the future. Differential revision: https://reviews.llvm.org/D128557 (cherry picked from commit 9bdb7e5)
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci please test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.