Add opt-in JSON logging with structured DNS query fields (#8553)

* plugin/pkg/log: add opt-in JSON logging backend

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>

* plugin/log: emit typed query records in JSON mode

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>

* coremain: expose process-wide JSON logging

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>

---------

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
This commit is contained in:
houyuwushang
2026-09-17 08:50:39 +08:00
committed by GitHub
parent 84a93a0b89
commit b93e449b2f
20 changed files with 1064 additions and 22 deletions

View File

@@ -21,7 +21,6 @@ func msg() *dns.Msg {
}
func TestNoDebug(t *testing.T) {
// Must come first, because set log.D.Set() which is impossible to undo.
var f bytes.Buffer
golog.SetOutput(&f)
@@ -45,6 +44,7 @@ func ExampleHexdump() {
}
func TestHexdump(t *testing.T) {
t.Cleanup(log.D.Clear)
var f bytes.Buffer
golog.SetOutput(&f)
log.D.Set()
@@ -59,6 +59,7 @@ func TestHexdump(t *testing.T) {
}
func TestHexdumpf(t *testing.T) {
t.Cleanup(log.D.Clear)
var f bytes.Buffer
golog.SetOutput(&f)
log.D.Set()