@@ -105,6 +105,7 @@ const char* funnytext = "*******************************************************
105105
106106bool g_anyToTcp;
107107bool g_8bitDNS;
108+ bool g_logDNSQueries;
108109#ifdef HAVE_LUA_RECORDS
109110bool g_doLuaRecord;
110111int g_luaRecordExecLimit;
@@ -568,6 +569,7 @@ static void sendout(std::unique_ptr<DNSPacket>& a, Logr::log_t slog, int start)
568569}
569570
570571// ! The qthread receives questions over the internet via the Nameserver class, and hands them to the Distributor for further processing
572+ // NOLINTNEXTLINE(readability-function-cognitive-complexity)
571573static void qthread (unsigned int num)
572574{
573575 std::shared_ptr<Logr::Logger> slog;
@@ -594,7 +596,6 @@ static void qthread(unsigned int num)
594596
595597 int diff{};
596598 int start{};
597- bool logDNSQueries = ::arg ().mustDo (" log-dns-queries" );
598599 shared_ptr<UDPNameserver> NS; // NOLINT(readability-identifier-length)
599600 std::string buffer;
600601 ComboAddress accountremote;
@@ -652,7 +653,7 @@ static void qthread(unsigned int num)
652653
653654 S.ringAccount (" queries" , question.qdomain , question.qtype );
654655 S.ringAccount (" remotes" , question.getInnerRemote ());
655- if (logDNSQueries ) {
656+ if (g_logDNSQueries ) {
656657 if (g_slogStructured) {
657658 if (question.d_ednsRawPacketSizeLimit > 0 && question.getMaxReplyLen () != (unsigned int )question.d_ednsRawPacketSizeLimit ) {
658659 slog->info (Logr::Notice, " Query received" , " remote" , Logging::Loggable (question.getRemoteString ()), " query" , Logging::Loggable (question.qdomain ), " type" , Logging::Loggable (question.qtype ), " dnssec" , Logging::Loggable (question.d_dnssecOk ), " max reply length" , Logging::Loggable (question.getMaxReplyLen ()), " raw packet size limit" , Logging::Loggable (question.d_ednsRawPacketSizeLimit ));
@@ -669,17 +670,22 @@ static void qthread(unsigned int num)
669670 }
670671 }
671672
673+ bool logAtNewline{false };
672674 if (PC.enabled () && (question.d .opcode != Opcode::Notify && question.d .opcode != Opcode::Update) && question.couldBeCached ()) {
673675 start = diff;
674676 std::string view{};
675677 if (g_views) {
678+ if (!g_slogStructured) {
679+ g_log << endl;
680+ logAtNewline = true ; // because of getViewFromNetwork below
681+ }
676682 Netmask netmask (accountremote);
677683 view = g_zoneCache.getViewFromNetwork (&netmask);
678684 }
679685 bool haveSomething = PC.get (question, cached, view); // does the PacketCache recognize this question?
680686 if (haveSomething) {
681- if (logDNSQueries ) {
682- SLOG (g_log << " : packetcache HIT" << endl,
687+ if (g_logDNSQueries ) {
688+ SLOG (g_log << (logAtNewline ? " " : " : " ) << " packetcache HIT" << endl,
683689 slog->info (Logr::Notice, " packetcache HIT" ));
684690 }
685691 cached.setRemote (&question.d_remote ); // inlined
@@ -706,17 +712,17 @@ static void qthread(unsigned int num)
706712 }
707713
708714 if (distributor->isOverloaded ()) {
709- if (logDNSQueries ) {
710- SLOG (g_log << " : Dropped query, backends are overloaded" << endl,
715+ if (g_logDNSQueries ) {
716+ SLOG (g_log << (logAtNewline ? " " : " : " ) << " Dropped query, backends are overloaded" << endl,
711717 slog->info (Logr::Notice, " Dropped query, backends are overloaded" ));
712718 }
713719 overloadDrops++;
714720 continue ;
715721 }
716722
717- if (logDNSQueries ) {
723+ if (g_logDNSQueries ) {
718724 if (PC.enabled ()) {
719- SLOG (g_log << " : packetcache MISS" << endl,
725+ SLOG (g_log << (logAtNewline ? " " : " : " ) << " packetcache MISS" << endl,
720726 slog->info (Logr::Notice, " packetcache MISS" ));
721727 }
722728 else {
@@ -772,6 +778,7 @@ static void mainthread()
772778
773779 g_anyToTcp = ::arg ().mustDo (" any-to-tcp" );
774780 g_8bitDNS = ::arg ().mustDo (" 8bit-dns" );
781+ g_logDNSQueries = ::arg ().mustDo (" log-dns-queries" );
775782#ifdef HAVE_LUA_RECORDS
776783 g_doLuaRecord = ::arg ().mustDo (" enable-lua-records" );
777784 g_LuaRecordSharedState = (::arg ()[" enable-lua-records" ] == " shared" );
@@ -968,6 +975,7 @@ static void mainthread()
968975 UeberBackend::go ();
969976
970977 // Setup the zone cache
978+ g_zoneCache.setSLog (slog);
971979 g_zoneCache.setRefreshInterval (::arg ().asNum (" zone-cache-refresh-interval" ));
972980 try {
973981 UeberBackend B;
0 commit comments