resolv: small improvements for debug logging
- use __func__ instead of the hand-written and often incorrect names
- fix a few cosmetic issues, such as those ugly ";;" prefixes
- add some logging around explore_fqdn and explore_numeric
- change the verbosity of a few messages
- replace compile-time DBG macro with verbosity checks in DnsProxyListener
- delete various unused functions in res_debug
- skip slow res_pquery() if log level is less than VERBOSE
TODO: convert the remaining ALOGx() lines to LOG(x). Leaving this for a
future patch.
Test: as follows:
adb shell setprop persist.sys.nw_dns_resolver_log DEBUG
atest reolv_integration_test
Change-Id: I7153f0c75d39d513fa006e0c1e5bf649d47ba154
diff --git a/resolv/res_cache.cpp b/resolv/res_cache.cpp
index b3c4370..35cad30 100644
--- a/resolv/res_cache.cpp
+++ b/resolv/res_cache.cpp
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-// NOTE: verbose logging MUST NOT be left enabled in production binaries.
-// It floods logs at high rate, and can leak privacy-sensitive information.
-constexpr bool kDumpData = false;
#define LOG_TAG "res_cache"
#include "resolv_cache.h"
@@ -55,6 +52,10 @@
#include "res_state_ext.h"
#include "resolv_private.h"
+// NOTE: verbose logging MUST NOT be left enabled in production binaries.
+// It floods logs at high rate, and can leak privacy-sensitive information.
+constexpr bool kDumpData = false;
+
/* This code implements a small and *simple* DNS resolver cache.
*
* It is only used to cache DNS answers for a time defined by the smallest TTL
@@ -1689,7 +1690,7 @@
struct addrinfo* nsaddrinfo[MAXNS];
if (numservers > MAXNS) {
- LOG(INFO) << __func__ << ": numservers=" << numservers << ", MAXNS=" << MAXNS;
+ LOG(ERROR) << __func__ << ": numservers=" << numservers << ", MAXNS=" << MAXNS;
return E2BIG;
}
@@ -1761,11 +1762,11 @@
// Always update the search paths, since determining whether they actually changed is
// complex due to the zero-padding, and probably not worth the effort. Cache-flushing
- // however is not // necessary, since the stored cache entries do contain the domain, not
+ // however is not necessary, since the stored cache entries do contain the domain, not
// just the host name.
- // code moved from res_init.c, load_domain_search_list
strlcpy(cache_info->defdname, domains, sizeof(cache_info->defdname));
if ((cp = strchr(cache_info->defdname, '\n')) != NULL) *cp = '\0';
+ LOG(INFO) << __func__ << ": domains=\"" << cache_info->defdname << "\"";
cp = cache_info->defdname;
offset = cache_info->dnsrch_offset;
@@ -1835,13 +1836,13 @@
if (statp == NULL) {
return;
}
+ LOG(INFO) << __func__ << "(netid=" << statp->netid << ")";
std::lock_guard guard(cache_mutex);
resolv_cache_info* info = find_cache_info_locked(statp->netid);
if (info != NULL) {
int nserv;
struct addrinfo* ai;
- LOG(INFO) << __func__ << ": " << statp->netid;
for (nserv = 0; nserv < MAXNS; nserv++) {
ai = info->nsaddrinfo[nserv];
if (ai == NULL) {