aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Andy Lindeman <andy@lindeman.io> 2022-06-05 13:17:00 -0400
committerGravatar GitHub <noreply@github.com> 2022-06-05 13:17:00 -0400
commit6e58595c613a32517dbfb92d82b520418832e8d1 (patch)
tree4e5fe233dfc930a2626bb355206be5f3a54412b4
parentf8f87e9e6dd56218a69cfb0e76be59512a54cff1 (diff)
downloadcoredns-6e58595c613a32517dbfb92d82b520418832e8d1.tar.gz
coredns-6e58595c613a32517dbfb92d82b520418832e8d1.tar.zst
coredns-6e58595c613a32517dbfb92d82b520418832e8d1.zip
Log the literal value, not a format string (#5425)
Signed-off-by: Andy Lindeman <andy@lindeman.io>
-rw-r--r--plugin/log/log.go2
-rw-r--r--plugin/log/log_test.go13
2 files changed, 14 insertions, 1 deletions
diff --git a/plugin/log/log.go b/plugin/log/log.go
index 7e6201138..78ed53407 100644
--- a/plugin/log/log.go
+++ b/plugin/log/log.go
@@ -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
diff --git a/plugin/log/log_test.go b/plugin/log/log_test.go
index 1914e05f3..e2f3acfdb 100644
--- a/plugin/log/log_test.go
+++ b/plugin/log/log_test.go
@@ -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 {