More helpful DNS failure message

Previously if dns.lua failed to resolve a name you'd see the following in your logs:
```
2019/10/12 23:39:34 [error] 41#41: *6474 [lua] dns.lua:121: dns_lookup(): failed to query the DNS server:
server returned error code: 3: name error
server returned error code: 3: name error, context: ngx.timer
```

Unfortunately this doesn't tell you what name is failing (so you have to start guessing). To alleviate the pain this simply adds the host name we are attempting to resolve to the log line so users don't have to guess.
This commit is contained in:
Thomas Jackson 2019-10-12 16:42:27 -07:00
parent a1a2950413
commit b698699fdd

View file

@ -118,7 +118,7 @@ function _M.lookup(host)
return addresses
end
ngx_log(ngx_ERR, "failed to query the DNS server:\n" .. table_concat(dns_errors, "\n"))
ngx_log(ngx_ERR, "failed to query the DNS server for %s:\n%s", host, table_concat(dns_errors, "\n"))
return { host }
end
@ -147,7 +147,7 @@ function _M.lookup(host)
end
if #dns_errors > 0 then
ngx_log(ngx_ERR, "failed to query the DNS server:\n" .. table_concat(dns_errors, "\n"))
ngx_log(ngx_ERR, "failed to query the DNS server for %s:\n%s", host, table_concat(dns_errors, "\n"))
end
return { host }