mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
This required a bit of an overhaul of the original integration of
JSON diagnostics into binlog.
The problem is that it is quite hard to add a kind of metadata to
binlog entries without changing its code. Another problem is that when
wanting to avoid double evaluation of logging macro arguments one
cannot really add a separate "diagnose" step easily.
The proposed solution consists in two things:
* hook into a binlog plumbing function by providing a better overload
resolution match, which happens after logging macro expansion,
bypassing the problem of double evaluation
* in that hook, produce the diagnostic directly, without waiting to
reconstruct the diagnostics entry from the binlog serialized entry.
This allows to forgo the weird category to diagnostic mapping, and now a
diagnostics emission simply happens when a diagnostic source is given
as the first argument after the log format string. A flavour of
diganostics sources with locations is then added with the same
mechanism, allowing to write something like
```cpp
LOG_ERROR("[{}] ouch!", internalError.withLocation("foo.swift", 32));
```
13 lines
235 B
Python
13 lines
235 B
Python
cc_library(
|
|
name = "logging",
|
|
srcs = glob(["*.cpp"]),
|
|
hdrs = glob(["*.h"]),
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"@absl//absl/strings",
|
|
"@binlog",
|
|
"@fmt",
|
|
"@json",
|
|
],
|
|
)
|