mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
logging: unify pkg/log and plugin/log (#2245)
Default to using pkg/log for all logging and use a fixed time prefix which is RFC3339Millli (doesn't exist in time, so we just extended RFC3339), i.e. Nano might be pushing it. Logs go from: 2018/10/30 19:14:55 [INFO] CoreDNS-1.2.5 2018/10/30 19:14:55 [INFO] linux/amd64, go1.11, to: 2018-10-30T19:10:07.547Z [INFO] CoreDNS-1.2.5 2018-10-30T19:10:07.547Z [INFO] linux/amd64, go1.11, Which includes the timezone - which oddly the std log package doesn't natively do. Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -35,13 +35,11 @@ func New(r *dns.Msg, rr *dnstest.Recorder, emptyValue string) Replacer {
|
||||
req := request.Request{W: rr, Req: r}
|
||||
rep := replacer{
|
||||
replacements: map[string]string{
|
||||
"{type}": req.Type(),
|
||||
"{name}": req.Name(),
|
||||
"{class}": req.Class(),
|
||||
"{proto}": req.Proto(),
|
||||
"{when}": func() string {
|
||||
return time.Now().Format(timeFormat)
|
||||
}(),
|
||||
"{type}": req.Type(),
|
||||
"{name}": req.Name(),
|
||||
"{class}": req.Class(),
|
||||
"{proto}": req.Proto(),
|
||||
"{when}": "", // made a noop
|
||||
"{size}": strconv.Itoa(req.Len()),
|
||||
"{remote}": addrToRFC3986(req.IP()),
|
||||
"{port}": req.Port(),
|
||||
@@ -163,7 +161,4 @@ func addrToRFC3986(addr string) string {
|
||||
return addr
|
||||
}
|
||||
|
||||
const (
|
||||
timeFormat = "02/Jan/2006:15:04:05 -0700"
|
||||
headerReplacer = "{>"
|
||||
)
|
||||
const headerReplacer = "{>"
|
||||
|
||||
Reference in New Issue
Block a user