Skip to content

Commit 5621005

Browse files
miodvallatHabbie
authored andcommitted
Tweak non-structured logs a bit.
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
1 parent 69c181a commit 5621005

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

pdns/auth-main.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,17 +669,22 @@ static void qthread(unsigned int num)
669669
}
670670
}
671671

672+
bool logAtNewline{false};
672673
if (PC.enabled() && (question.d.opcode != Opcode::Notify && question.d.opcode != Opcode::Update) && question.couldBeCached()) {
673674
start = diff;
674675
std::string view{};
675676
if (g_views) {
677+
if (!g_slogStructured) {
678+
g_log << endl;
679+
logAtNewline = true; // because of getViewFromNetwork below
680+
}
676681
Netmask netmask(accountremote);
677682
view = g_zoneCache.getViewFromNetwork(&netmask);
678683
}
679684
bool haveSomething = PC.get(question, cached, view); // does the PacketCache recognize this question?
680685
if (haveSomething) {
681686
if (g_logDNSQueries) {
682-
SLOG(g_log << ": packetcache HIT" << endl,
687+
SLOG(g_log << (logAtNewline ? "" : ": ") << "packetcache HIT" << endl,
683688
slog->info(Logr::Notice, "packetcache HIT"));
684689
}
685690
cached.setRemote(&question.d_remote); // inlined
@@ -707,7 +712,7 @@ static void qthread(unsigned int num)
707712

708713
if (distributor->isOverloaded()) {
709714
if (g_logDNSQueries) {
710-
SLOG(g_log << ": Dropped query, backends are overloaded" << endl,
715+
SLOG(g_log << (logAtNewline ? "" : ": ") << "Dropped query, backends are overloaded" << endl,
711716
slog->info(Logr::Notice, "Dropped query, backends are overloaded"));
712717
}
713718
overloadDrops++;
@@ -716,7 +721,7 @@ static void qthread(unsigned int num)
716721

717722
if (g_logDNSQueries) {
718723
if (PC.enabled()) {
719-
SLOG(g_log << ": packetcache MISS" << endl,
724+
SLOG(g_log << (logAtNewline ? "" : ": ") << "packetcache MISS" << endl,
720725
slog->info(Logr::Notice, "packetcache MISS"));
721726
}
722727
else {

pdns/tcpreceiver.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,16 +407,21 @@ void TCPNameserver::doConnection(int fd, Logr::log_t slog)
407407
}
408408
}
409409

410+
bool logAtNewline{false};
410411
if (PC.enabled()) {
411412
if (packet->couldBeCached()) {
412413
std::string view{};
413414
if (g_views) {
415+
if (!g_slogStructured) {
416+
g_log << endl;
417+
logAtNewline = true; // because of getViewFromNetwork below
418+
}
414419
Netmask netmask(packet->getInnerRemote());
415420
view = g_zoneCache.getViewFromNetwork(&netmask);
416421
}
417422
if (PC.get(*packet, *cached, view)) { // short circuit - does the PacketCache recognize this question?
418423
if(g_logDNSQueries) {
419-
SLOG(g_log<<": packetcache HIT"<<endl,
424+
SLOG(g_log << (logAtNewline ? "" : ": ") << "packetcache HIT"<<endl,
420425
slogger->info(Logr::Notice, "Received TCP query", "packetcache", Logging::Loggable("hit")));
421426
}
422427
cached->setRemote(&packet->d_remote);
@@ -430,7 +435,7 @@ void TCPNameserver::doConnection(int fd, Logr::log_t slog)
430435
}
431436
}
432437
if(g_logDNSQueries) {
433-
SLOG(g_log<<": packetcache MISS"<<endl,
438+
SLOG(g_log<< (logAtNewline ? "" : ": ") << "packetcache MISS"<<endl,
434439
slogger->info(Logr::Notice, "Received TCP query", "packetcache", Logging::Loggable("miss")));
435440
}
436441
} else {

0 commit comments

Comments
 (0)