Log the literal value, not a format string (#5425)

Signed-off-by: Andy Lindeman <andy@lindeman.io>
This commit is contained in:
Andy Lindeman 2022-06-05 13:17:00 -04:00 committed by GitHub
parent f8f87e9e6d
commit 6e58595c61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -46,7 +46,7 @@ func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
}
if ok || ok1 {
logstr := l.repl.Replace(ctx, state, rrw, rule.Format)
clog.Infof(logstr)
clog.Info(logstr)
}
return rc, err

View file

@ -202,6 +202,19 @@ func TestLogged(t *testing.T) {
ShouldLog: true,
ShouldString: "\"0\"",
},
{
Rules: []Rule{
{
NameScope: ".",
Format: CombinedLogFormat,
Class: map[response.Class]struct{}{response.All: {}},
},
},
Domain: "foo.%s.example.org.",
ShouldLog: true,
ShouldString: "foo.%s.example.org.",
ShouldNOTString: "%!s(MISSING)",
},
}
for _, tc := range tests {