]> granicus.if.org Git - pdns/commitdiff
add query-logging support for the bindbackend sqlite3 dnssec database. Closes #563...
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Fri, 9 Nov 2012 10:17:12 +0000 (10:17 +0000)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Fri, 9 Nov 2012 10:17:12 +0000 (10:17 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2874 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/backends/bind/binddnssec.cc
pdns/backends/gsql/gsqlbackend.cc
pdns/ssqlite3.cc
pdns/ssqlite3.hh

index 732f9f97dda4a2cc79b5716dc4d3faef9064589c..fc4c43eefe7a8c2d19acdf041e6bc9abeca222a3 100644 (file)
 #include "bind-dnssec.schema.sqlite3.sql.h"
 #include <boost/foreach.hpp>
 #include "config.h"
+#include "pdns/arguments.hh"
 
 #ifndef HAVE_SQLITE3
 void Bind2Backend::setupDNSSEC()
 {
   if(!getArg("dnssec-db").empty())
     throw runtime_error("bind-dnssec-db requires building PowerDNS with SQLite3");
+
+  d_dnssecdb->setLog(::arg().mustDo("query-logging"));
 }
 
 void Bind2Backend::createDNSSECDB(const string& fname)
index 561cc4074d283a46f538b2bb5b9d46d988b22e00..88cf0734d3a3922dd2ae607e6fc4e353eda7e140 100644 (file)
@@ -729,7 +729,6 @@ void GSQLBackend::lookup(const QType &qtype,const string &qname, DNSPacket *pkt_
       snprintf(output,sizeof(output)-1, format.c_str(),sqlEscape(lcqname).c_str(),domain_id);
     }
   }
-  DLOG(L<< "Query: '" << output << "'"<<endl);
 
   try {
     d_db->doQuery(output);
index 0af71ac668f33f58525cffc4dd3b9638c4eb31f0..5598b044ab084be5c395a3a8ff514e91516b0b98 100644 (file)
@@ -4,10 +4,13 @@
 // Copyright (C) 2003, Michel Stol <michel@powerdns.com>
 //
 
-#include "pdns/utility.hh"
 #include <string>
+#include <sstream>
 #include "ssqlite3.hh"
 #include <iostream>
+#include <fstream>
+#include "pdns/logger.hh"
+#include "misc.hh"
 
 #ifdef WIN32
 # include <io.h>
@@ -31,6 +34,11 @@ SSQLite3::SSQLite3( const std::string & database, bool creat )
   sqlite3_busy_handler(m_pDB, busyHandler, 0);
 }
 
+void SSQLite3::setLog(bool state)
+{
+  s_dolog=state;
+}
+
 // Destructor.
 SSQLite3::~SSQLite3()
 {
@@ -77,8 +85,12 @@ int SSQLite3::doQuery( const std::string & query, result_t & result )
 int SSQLite3::doQuery( const std::string & query )
 {
   const char *pTail;
-  // Execute the query.
+
+  if(s_dolog)
+    L<<Logger::Warning<<"Query: "<<query<<endl;
   
+  // Execute the query.
+
 #if SQLITE_VERSION_NUMBER >=  3003009
   if ( sqlite3_prepare_v2( m_pDB, query.c_str(), -1, &m_pStmt, &pTail ) != SQLITE_OK )
 #else
index 7b3c3cf1126768449b478351b918b370da790c78..42c2502f2c232dce101dbb3b91b76bd7f74195ab 100644 (file)
@@ -19,6 +19,8 @@ private:
   //! Pointer to the SQLite virtual machine executing a query.
   sqlite3_stmt *m_pStmt;
 
+  bool s_dolog;
+
   static int busyHandler(void*, int);
 protected:
 public:
@@ -47,6 +49,8 @@ public:
   //! Escapes the SQL query.
   std::string escape( const std::string & query );
 
+  void setLog(bool state);
+
   //! Used to create an backend specific exception message.
   SSqlException sPerrorException( const std::string & reason );
 };