Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edf67685 authored by Bernie Innocenti's avatar Bernie Innocenti
Browse files

Add an explicit VERBOSE log level

Now it's possible to set the level to VERBOSE and DEBUG independently in
debug builds.

Setting the level to VERBOSE in a release build is equivalent to
setting it to DEBUG.

Test: - build, flash
      - adb shell setprop persist.sys.nw_dns_resolver_log VERBOSE
      - adb logcat | grep libnetd_resolv
Change-Id: Ieafa90fa31e74490203d9d0d8c4f548a68ed3504
parent fb8641c6
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@
 */

#define LOG_TAG "res_debug"
#define DBG 0

#include <sys/param.h>
#include <sys/socket.h>
@@ -118,6 +117,14 @@

#include "resolv_private.h"

// Default to disabling verbose logging unless overridden by Android.bp
// for debuggable builds.
//
// NOTE: Verbose resolver logs could contain PII -- do NOT enable in production builds
#ifndef RESOLV_ALLOW_VERBOSE_LOGGING
#define RESOLV_ALLOW_VERBOSE_LOGGING 0
#endif

struct res_sym {
    int number;            /* Identifying number, like T_MX */
    const char* name;      /* Its symbolic name, like "MX" */
@@ -502,11 +509,11 @@ const char* p_rcode(int rcode) {
android::base::LogSeverity logSeverityStrToEnum(const std::string& logSeverityStr) {
    android::base::LogSeverity logSeverityEnum;

    if (logSeverityStr == "DEBUG") {
    if (logSeverityStr == "VERBOSE") {
        // *** enable verbose logging only when DBG is set. It prints sensitive data ***
        if (DBG)
            logSeverityEnum = android::base::VERBOSE;
        else
        logSeverityEnum =
                RESOLV_ALLOW_VERBOSE_LOGGING ? android::base::VERBOSE : android::base::DEBUG;
    } else if (logSeverityStr == "DEBUG") {
        logSeverityEnum = android::base::DEBUG;
    } else if (logSeverityStr == "INFO") {
        logSeverityEnum = android::base::INFO;