Parcourir la source

Some more logging messages

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/vorner-recursor-dummylog@3556 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner il y a 14 ans
Parent
commit
888f88f112

+ 9 - 1
src/bin/recurse/main.cc

@@ -22,7 +22,7 @@
 #include <stdlib.h>
 #include <errno.h>
 
-#include <cassert>
+#include <string>
 #include <iostream>
 
 #include <boost/foreach.hpp>
@@ -166,6 +166,14 @@ main(int argc, char* argv[]) {
         usage();
     }
 
+    if (isc::log::denabled) { // Show the command line
+        string cmdline("Command line:");
+        for (int i = 0; i < argc; ++ i) {
+            cmdline = cmdline + " " + argv[i];
+        }
+        dlog(cmdline);
+    }
+
     int ret = 0;
 
     // XXX: we should eventually pass io_service here.

+ 8 - 2
src/bin/recurse/recursor.cc

@@ -114,7 +114,8 @@ public:
         message_(message), section_(sect), sign_(sign)
     {}
     void operator()(const RRsetPtr rrset) {
-        dlog("Adding RRSet to message");
+        dlog("Adding RRSet to message section " +
+            boost::lexical_cast<string>(section_.getCode()));
         message_->addRRset(section_, rrset, true);
     }
     MessagePtr message_;
@@ -354,10 +355,15 @@ Recursor::processMessage(const IOMessage& io_message, MessagePtr message,
     bool sendAnswer = true;
     if (message->getOpcode() == Opcode::NOTIFY()) {
         makeErrorMessage(message, buffer, Rcode::NOTAUTH());
+        dlog("Notify arrived, but we are not authoritative");
     } else if (message->getOpcode() != Opcode::QUERY()) {
-        dlog("unsupported opcode");
+        dlog("Unsupported opcode (got: " + message->getOpcode().toText() +
+            ", expected: " + Opcode::QUERY().toText());
         makeErrorMessage(message, buffer, Rcode::NOTIMP());
     } else if (message->getRRCount(Section::QUESTION()) != 1) {
+        dlog("The query contained " +
+            boost::lexical_cast<string>(message->getRRCount(
+            Section::QUESTION()) + " questions, exactly one expected"));
         makeErrorMessage(message, buffer, Rcode::FORMERR());
     } else {
         ConstQuestionPtr question = *message->beginQuestion();

+ 2 - 1
src/lib/asiolink/asiolink.cc

@@ -234,7 +234,8 @@ void
 RecursiveQuery::sendQuery(const Question& question, OutputBufferPtr buffer,
                           DNSServer* server)
 {
-    dlog("Sending upstream query to " + ns_addr_.toText());
+    dlog("Sending upstream query (" + question.toText() + ") to " +
+        ns_addr_.toText());
     // XXX: eventually we will need to be able to determine whether
     // the message should be sent via TCP or UDP, or sent initially via
     // UDP and then fall back to TCP on failure, but for the moment

+ 6 - 0
src/lib/asiolink/udpdns.cc

@@ -29,6 +29,7 @@
 #include <dns/buffer.h>
 #include <dns/message.h>
 #include <dns/messagerenderer.h>
+#include <log/dummylog.h>
 
 #include <asiolink.h>
 #include <internal/coroutine.h>
@@ -37,6 +38,7 @@
 using namespace asio;
 using asio::ip::udp;
 using asio::ip::tcp;
+using isc::log::dlog;
 
 using namespace std;
 using namespace isc::dns;
@@ -208,6 +210,8 @@ UDPQuery::operator()(error_code ec, size_t length) {
             msg.addQuestion(question_);
             MessageRenderer renderer(*msgbuf_);
             msg.toWire(renderer);
+            dlog("Sending " + msg.toText() + " to " +
+                remote_.address().to_string());
         }
 
         // Begin an asynchronous send, and then yield.  When the
@@ -224,6 +228,8 @@ UDPQuery::operator()(error_code ec, size_t length) {
         /// completes, we will resume immediately after this point.
         CORO_YIELD socket_->async_receive_from(buffer(data_.get(), MAX_LENGTH),
                                                remote_, *this);
+        // The message is not rendered yet, so we can't print it easilly
+        dlog("Received response from " + remote_.address().to_string());
 
         /// Copy the answer into the response buffer.  (XXX: If the
         /// OutputBuffer object were made to meet the requirements of