mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 02:03:20 -04:00 
			
		
		
		
	Document log replacements
Rename latency to duration.
This commit is contained in:
		| @@ -33,7 +33,26 @@ CoreDNS will create it before appending to it. | ||||
|  | ||||
| ## Log Format | ||||
|  | ||||
| You can specify a custom log format with any placeholder values. Log supports both request and response placeholders. | ||||
| You can specify a custom log format with any placeholder values. Log supports both request and | ||||
| response placeholders. | ||||
|  | ||||
| The following place holders are supported: | ||||
|  | ||||
| * `{type}`: qtype of the request. | ||||
| * `{name}`: qname of the request. | ||||
| * `{class}`: class of the request. | ||||
| * `{proto}`: protocol used (tcp or udp). | ||||
| * `{when}`: time of the query. | ||||
| * `{remote}`: client's IP address. | ||||
| * `{port}`: client's port. | ||||
| * `{rcode}`: response RCODE. | ||||
| * `{size}`: response size. | ||||
| * `{duration}`: response duration (in seconds). | ||||
| * `{>bufsize}`: the EDNS0 buffer size advertized by the client. | ||||
| * `{>do}`: is the EDNS0 DO (DNSSEC OK) bit set. | ||||
| * `{>id}`: query ID | ||||
| * `{>opcode}`: query OPCODE | ||||
|  | ||||
|  | ||||
| ## Log Rotation | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package middleware | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"time" | ||||
| @@ -54,13 +55,15 @@ func NewReplacer(r *dns.Msg, rr *ResponseRecorder, emptyValue string) Replacer { | ||||
| 		} | ||||
| 		rep.replacements["{rcode}"] = rcode | ||||
| 		rep.replacements["{size}"] = strconv.Itoa(rr.size) | ||||
| 		rep.replacements["{latency}"] = time.Since(rr.start).String() | ||||
| 		rep.replacements["{duration}"] = time.Since(rr.start).String() | ||||
| 	} | ||||
|  | ||||
| 	// Header placeholders (case-insensitive) | ||||
| 	// TODO(miek): syntax for flags and document it | ||||
| 	rep.replacements[headerReplacer+"id}"] = strconv.Itoa(int(r.Id)) | ||||
| 	rep.replacements[headerReplacer+"opcode}"] = strconv.Itoa(int(r.Opcode)) | ||||
| 	rep.replacements[headerReplacer+"do}"] = fmt.Sprintf("%b", state.Do()) | ||||
| 	rep.replacements[headerReplacer+"bufsize}"] = strconv.Itoa(state.Size()) | ||||
|  | ||||
| 	return rep | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user