-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Swift: add infrastructure for emitting JSON diagnostics #13012
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
Conversation
New `DIAGNOSE_ERROR` and `DIAGNOSE_CRITICAL` macros are added. These accept an ID which should indicate a diagnostic source via a function definition in `codeql::diagnostics`, together with the usual format + arguments accepted by other `LOG_*` macros. When the log is flushed, these special logs will result in an error JSON diagnostic entry in the database.
swift/log/SwiftDiagnostics.h
Outdated
namespace diagnostics { | ||
inline void internal_error() { | ||
SwiftDiagnosticsSource::create("internal_error", "Internal error", {}, | ||
"Contact us about this issue"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs rewording and proper links, but in any case it's not used yet
I've tested it on a dummy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High-level LGTM, but left a few implementation comments.
@sashabu I've somewhat simplified how diagnostics source are defined, a more direct |
New
DIAGNOSE_ERROR
andDIAGNOSE_CRITICAL
macros are added. These accept an ID which should indicate aSwiftDiagnosticsSource
definition incodeql_diagnostics
, together with the usual format + arguments accepted by otherLOG_*
macros. This peculiar API was somewhat conditioned by binlog's API: its macros take a category that is then stringified before usage (as opposed to accepting a string directly). In particular in order to use the category as a diagnostic source discriminant we cannot rely on any kind of evaluation giving us the category to use.When the log is flushed, these special logs will result in an error JSON diagnostic entry in the database.
Also this moves all the logging infrastructure in a common
log
directory withinswift
, as this will need to be used by thexcode-autobuilder
as well.