From 0b7def873341ffff11f5f08516f1c9d634b6dac6 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 4 Feb 2019 17:02:21 +0300 Subject: [PATCH] Add dns_resolver log tag. GitOrigin-RevId: 17fed9f8350bb49e18b875ed21290c7805875df6 --- td/telegram/Logging.cpp | 15 ++++++++------- tdnet/td/net/GetHostByNameActor.cpp | 13 ++++++++----- tdnet/td/net/GetHostByNameActor.h | 3 +++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/td/telegram/Logging.cpp b/td/telegram/Logging.cpp index c7c1bd7e0..f072dc167 100644 --- a/td/telegram/Logging.cpp +++ b/td/telegram/Logging.cpp @@ -14,9 +14,10 @@ #include "td/telegram/Td.h" #include "td/telegram/UpdatesManager.h" -#include "tddb/td/db/binlog/BinlogEvent.h" +#include "td/db/binlog/BinlogEvent.h" -#include "tdnet/td/net/TransparentProxy.h" +#include "td/net/GetHostByNameActor.h" +#include "td/net/TransparentProxy.h" #include "td/utils/FileLog.h" #include "td/utils/logging.h" @@ -35,11 +36,11 @@ static NullLog null_log; #define ADD_TAG(tag) \ { #tag, &VERBOSITY_NAME(tag) } static const std::map log_tags{ - ADD_TAG(td_init), ADD_TAG(update_file), ADD_TAG(connections), ADD_TAG(binlog), - ADD_TAG(proxy), ADD_TAG(net_query), ADD_TAG(td_requests), ADD_TAG(dc), - ADD_TAG(files), ADD_TAG(mtproto), ADD_TAG(raw_mtproto), ADD_TAG(fd), - ADD_TAG(actor), ADD_TAG(buffer), ADD_TAG(sqlite), ADD_TAG(notifications), - ADD_TAG(get_difference), ADD_TAG(file_gc), ADD_TAG(config_recoverer)}; + ADD_TAG(td_init), ADD_TAG(update_file), ADD_TAG(connections), ADD_TAG(binlog), + ADD_TAG(proxy), ADD_TAG(net_query), ADD_TAG(td_requests), ADD_TAG(dc), + ADD_TAG(files), ADD_TAG(mtproto), ADD_TAG(raw_mtproto), ADD_TAG(fd), + ADD_TAG(actor), ADD_TAG(buffer), ADD_TAG(sqlite), ADD_TAG(notifications), + ADD_TAG(get_difference), ADD_TAG(file_gc), ADD_TAG(config_recoverer), ADD_TAG(dns_resolver)}; #undef ADD_TAG Status Logging::set_current_stream(td_api::object_ptr stream) { diff --git a/tdnet/td/net/GetHostByNameActor.cpp b/tdnet/td/net/GetHostByNameActor.cpp index a76877c37..3208bbbe2 100644 --- a/tdnet/td/net/GetHostByNameActor.cpp +++ b/tdnet/td/net/GetHostByNameActor.cpp @@ -79,8 +79,9 @@ class GoogleDnsResolver : public Actor { void on_result(Result r_http_query) { auto end_time = Time::now(); auto result = get_ip_address(std::move(r_http_query)); - LOG(WARNING) << "Init IPv" << (prefer_ipv6_ ? "6" : "4") << " host = " << host_ << " in " << end_time - begin_time_ - << " seconds to " << (result.is_ok() ? (PSLICE() << result.ok()) : CSlice("[invalid]")); + VLOG(dns_resolver) << "Init IPv" << (prefer_ipv6_ ? "6" : "4") << " host = " << host_ << " in " + << end_time - begin_time_ << " seconds to " + << (result.is_ok() ? (PSLICE() << result.ok()) : CSlice("[invalid]")); promise_.set_result(std::move(result)); stop(); } @@ -102,7 +103,7 @@ class NativeDnsResolver : public Actor { auto begin_time = Time::now(); auto status = ip.init_host_port(host_, 0, prefer_ipv6_); auto end_time = Time::now(); - LOG(WARNING) << "Init host = " << host_ << " in " << end_time - begin_time << " seconds to " << ip; + VLOG(dns_resolver) << "Init host = " << host_ << " in " << end_time - begin_time << " seconds to " << ip; if (status.is_error()) { promise_.set_error(std::move(status)); } else { @@ -114,6 +115,8 @@ class NativeDnsResolver : public Actor { } // namespace detail +int VERBOSITY_NAME(dns_resolver) = VERBOSITY_NAME(DEBUG); + GetHostByNameActor::GetHostByNameActor(Options options) : options_(std::move(options)) { CHECK(!options_.resolver_types.empty()); } @@ -181,8 +184,8 @@ void GetHostByNameActor::on_query_result(std::string host, bool prefer_ipv6, Res } auto end_time = Time::now(); - LOG(WARNING) << "Init host = " << query.real_host << " in total of " << end_time - query.begin_time << " seconds to " - << (result.is_ok() ? (PSLICE() << result.ok()) : CSlice("[invalid]")); + VLOG(dns_resolver) << "Init host = " << query.real_host << " in total of " << end_time - query.begin_time + << " seconds to " << (result.is_ok() ? (PSLICE() << result.ok()) : CSlice("[invalid]")); auto promises = std::move(query.promises); auto value_it = cache_[prefer_ipv6].find(host); diff --git a/tdnet/td/net/GetHostByNameActor.h b/tdnet/td/net/GetHostByNameActor.h index 87a040b92..0d8883dc5 100644 --- a/tdnet/td/net/GetHostByNameActor.h +++ b/tdnet/td/net/GetHostByNameActor.h @@ -9,6 +9,7 @@ #include "td/actor/actor.h" #include "td/actor/PromiseFuture.h" +#include "td/utils/logging.h" #include "td/utils/port/IPAddress.h" #include "td/utils/Status.h" @@ -16,6 +17,8 @@ namespace td { +extern int VERBOSITY_NAME(dns_resolver); + class GetHostByNameActor final : public Actor { public: enum class ResolverType { Native, Google };