Log the literal value, not a format string (#5425)
Signed-off-by: Andy Lindeman <andy@lindeman.io>
This commit is contained in:
parent
f8f87e9e6d
commit
6e58595c61
2 changed files with 14 additions and 1 deletions
|
@ -46,7 +46,7 @@ func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||||
}
|
}
|
||||||
if ok || ok1 {
|
if ok || ok1 {
|
||||||
logstr := l.repl.Replace(ctx, state, rrw, rule.Format)
|
logstr := l.repl.Replace(ctx, state, rrw, rule.Format)
|
||||||
clog.Infof(logstr)
|
clog.Info(logstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc, err
|
return rc, err
|
||||||
|
|
|
@ -202,6 +202,19 @@ func TestLogged(t *testing.T) {
|
||||||
ShouldLog: true,
|
ShouldLog: true,
|
||||||
ShouldString: "\"0\"",
|
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 {
|
for _, tc := range tests {
|
||||||
|
|
Loading…
Add table
Reference in a new issue