mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
plugin/log - Support for Metadata (#2251)
* - add metadata support to Log * - adapt ctx after rebase
This commit is contained in:
committed by
John Belamaric
parent
35c5474660
commit
94c9aae323
@@ -61,6 +61,7 @@ The following place holders are supported:
|
||||
* `{class}`: qclass of the request
|
||||
* `{proto}`: protocol used (tcp or udp)
|
||||
* `{remote}`: client's IP address, for IPv6 addresses these are enclosed in brackets: `[::1]`
|
||||
* `{local}`: server's IP address, for IPv6 addresses these are enclosed in brackets: `[::1]`
|
||||
* `{size}`: request size in bytes
|
||||
* `{port}`: client's port
|
||||
* `{duration}`: response duration
|
||||
@@ -72,6 +73,10 @@ The following place holders are supported:
|
||||
* `{>do}`: is the EDNS0 DO (DNSSEC OK) bit set in the query
|
||||
* `{>id}`: query ID
|
||||
* `{>opcode}`: query OPCODE
|
||||
* `{/[LABEL]}`: any metadata label is accepted as a place holder if it is enclosed between `{/` and `}`.
|
||||
the place holder will be replaced by the corresponding metadata value or the default value `-` if label is not defined.
|
||||
|
||||
|
||||
|
||||
The default Common Log Format is:
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||
// If we don't set up a class in config, the default "all" will be added
|
||||
// and we shouldn't have an empty rule.Class.
|
||||
if rule.Class[response.All] || rule.Class[class] {
|
||||
rep := replacer.New(r, rrw, CommonLogEmptyValue)
|
||||
rep := replacer.New(ctx, r, rrw, CommonLogEmptyValue)
|
||||
clog.Infof(rep.Replace(rule.Format))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user